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

> -----Original Message-----
> From: Brian Beaudet [mailto:[EMAIL PROTECTED] 
> Sent: 17 February 2004 22:08
> To: [email protected]
> Subject: Prevent Logging Headers/Footers
> 
> 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>
> 
>  
> 
> 

Reply via email to