Below is the Section of log4net from app.config
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net debug="true">
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file type="log4net.Util.PatternString" value="${TMP}\SRG\Logs\Log_%env{USERNAME}_%date{yyyyMMdd}.log" />
<appendToFile value="true" />
<bufferSize value="20" />
<LockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<layout type="log4net.Layout.PatternLayout">
<header type="log4net.Util.PatternString" value="[Log Starts]%newline" />
<footer type="log4net.Util.PatternString" value="[Log Ends]%newline" />
<conversionPattern value="%date [%username] - %message%newline" />
</layout>
</appender>
<logger name="SRGApplicationDebugLog">
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</logger>
</log4net>
Problem 1: I am getting header and footer two times extra whenever my application is started, but I need to avoid it.
[Log Starts]
[Log Ends]
[Log Starts]
[Log Ends]
[Log Starts]
2012-11-08 12:25:03,376 [username] - Application started
[Log Ends]
Problem 2: I am not getting from where is the two empty header footer pair is coming.
- I am creating logger like below:
_debugLogger = LogManager.GetLogger("SRGApplicationDebugLog");
XmlConfigurator.Configure();
- To use Logger:
_debugLogger.DebugFormat(logMessage);
- I have added this line explicitly in AssemblyInfo.cs for log4net
[assembly: XmlConfigurator(Watch = true)]
Question: Want to fix the problems in bold