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.
_debugLogger = LogManager.GetLogger("SRGApplicationDebugLog");
XmlConfigurator.Configure();
_debugLogger.DebugFormat(logMessage);
[assembly: XmlConfigurator(Watch = true)]
Question: Want to fix the problems in bold
You don't need
XmlConfigurator.Configure();
if you have
[assembly: XmlConfigurator(Watch = true)]
Having both will result in the two headers and two footers.
As to why you have three sets, perhaps you are calling XmlConfigurator.Configure() twice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With