Error Configuring Log4Net EventLogAppender

4.7k views Asked by At

I have a console application using Log4Net 1.2.10.0. I added an EventLogAppender in my Log4Net config:

<apender name="eventLogAppender" type="log4net.Appender.EventLogAppender,log4net" >
    <mapping>
        <level value="ERROR" />
        <eventLogEntryType value="Error" />
    </mapping>
    <mapping>
        <level value="DEBUG" />
        <eventLogEntryType value="Information" />
    </mapping>
    <mapping>
        <level value="INFO" />
        <eventLogEntryType value="Information" />
    </mapping>
    <mapping>
        <level value="WARN" />
        <eventLogEntryType value="Warning" />
    </mapping>
    <layout type="log4net.Layout.PatternLayout,log4net">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
</apender>

When I call XmlConfigurator.Configure(); I get the following error:

log4net: XmlHierarchyConfigurator: Configuration update mode [Merge].
log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [apender] to set object on [log4net.Repository.Hierarchy.Hierarchy]

Then later on I get an error stating that the appender "eventLogAppender" does not exist. Most likely due to the fact that the appender failed during the configuration.

I don't think it's a permissions issue but I tried that anyways and still no luck.

1

There are 1 answers

1
IAmTimCorey On BEST ANSWER

Appender has two "p"'s in it. Fix that and you should be good. Your line is currently

<apender name="eventLogAppender" type="log4net.Appender.EventLogAppender,log4net" >

and it should be

<appender name="eventLogAppender" type="log4net.Appender.EventLogAppender,log4net" >

Don't forget to also change your closing line from

</apender>

to

</appender>