开发者

Error Configuring Log4Net EventLogAppender

开发者 https://www.devze.com 2023-03-14 21:37 出处:网络
I have a console application using Log4Net 1.2.10.0.I added an EventLogAppender in my Log4Net config:

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 开发者_StackOverflowI tried that anyways and still no luck.


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消