The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.
| Author |
Messages |
|
Brian Beaudet
 |
| 02/17/2004 11:08 PM |
|
I’m using a RollingFileAppender and when I set the root’s level-value to “OFF”, I’d like the header and footer not to be appended to my log file. How do I do that? Currently, the header/footer gets appended to my log each time by application starts and stops. Here’s my configuration code:
<log4net>
<root>
<level value="NONE"/>
<appender-ref ref="RollingLogFileAppender" />
</root>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="TPEMigrationTool.log" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="10" />
<param name="MaximumFileSize" value="100KB" />
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="********************[Header]********************\r\n" />
<param name="Footer" value="********************[Footer]********************\r\n" />
<param name="ConversionPattern" value="%d [%t] %-5p %c{2} [%x] - %m%n" />
</layout>
</appender>
</log4net>
|
|
|
|
|
Nicko Cadell
 |
| 02/21/2004 11:52 PM |
|
Brian,
The header / footer functionality of the FileAppender is triggered by the opening and closing of the file. Therefore the header and footer are written to the file even if no events are logged.
If you set the logging level to OFF you may as well also comment out the <appender-ref ref="RollingLogFileAppender" /> line. If the appender is not referenced it will not be loaded, therefore the file will not be opened, the header won't be written etc...
If you need to reference the appender because you want to programmatically change the logging level then you will need to modify the FileAppender and RollingFileAppender to only log the header when the first event arrives.
Nicko
|
|
|
|
|
|
| You are not authorized to post a reply. |
|
|
|
ActiveForums 3.7
|