I used RollingFileAppender. And I want add a blank line to the log when my program launches. How to do that? Thanks.
Edit: OK, thanks for you all. Sorry for the confused question I asked. Let me make some explanation. I config the log4net as follows:
<log4net>
<appender name="MyFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="ClientLog.log" />
<param name="AppendToFile" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date{yyyy/MM/dd HH:mm:ss},%5p,%m%n" />
</layout>
</appender>
<logger name="GlobalUse" >
<level value="Info"/>
<appender-ref ref="MyFileAppender" />
</logger>
</log4net>
and the log will be:
2010/03/27 13:55:27, INFO, Program start.
2010/03/27 13:55:29, INFO, Program end.
2010/03/27 13:56:30, INFO, Program start.
2010/03/27 13:56:32, INFO, Program end.
What i hope is make the log looks like this:
2010/03/27 13:55:27, INFO, Program start.
2010/03/27 13:55:29, INFO, Program end.
2010/03/27 13:56:30, INFO, Program start.
2010/03/27 13:56:32, INFO, Program end.
2010/03/27 13:57:30, INFO, Program start.
...
Any idea? Thanks.
The selected answer is MUCH more difficult than it needs to be. I'm not sure if it didn't exist when the question was originally asked, but the correct way to do this is with a <header>
or <footer>
in the appender's layout. Something like this:
<layout type="log4net.Layout.PatternLayout">
<footer value=" " />
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
That will insert a blank line as a footer to each logging run. More detail is here: http://logging.apache.org/log4net/release/faq.html#layout-header-xml-newlines
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