I am using log4net for logging, I have two appenders one file and other eventlog appender. I have register application in registry editor, problem is now both logger are writing in event viewer. I need fileAppender
to write in file and eventLogAppender
to be shown in event viewer.
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="file.log"/>
<appendToFile value="false"/>
<layout type="log4net.Layout.PatternLayout">
<header value="Logging Start 
"/>
<footer value="Logging End 
"/>
<conversionPattern value="%date [%thread] %-5level %logger: %message%newline"/>
</layout>
</appender>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
<param name="ApplicationName" value="eventlog" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="LogFileAppender"/>
<appender-ref ref="EventLogAppender" />
</root>
</log4net>
and then in code
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog log = LogManager.GetLogger("LogFileAppender");
private static readonly ILog logEvents = LogManager.GetLogger("EventLogAppender");
I have tried different things but no one is working, any solution?
Thanks!