Thursday, July 02, 2009
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

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.

Subject: configurable file purging and logging to two files
Prev Next
You are not authorized to post a reply.

Author Messages
Scribner, Aaron

08/03/2006 3:27 PM  
1) Is there a configuration option for having files, say older than 14 days, purged from the hard drive?
 
2) I am logging particular events to a separate file and have that working. The problem arises from the fact that these events are logged both to my main log file and also to the separate file. What in my configuration needs some tweaking?
 
 <log4net>
  <appender name="WndAppender" type="CustomAppenderes.InternalAppender, InternalAppender">
   <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%d{HH:mm:ss} [%t]\t%-5p\t%c{3} [%x] - %m"/>
                
   </layout>
  </appender>
  <appender name="TraceAppender" type="log4net.Appender.TraceAppender" >
   <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
   </layout>
  </appender>
  
  <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
   <param name="File" value="./Logs/log-file.txt" />
   <param name="AppendToFile" value="true" />
   <param name="MaxSizeRollBackups" value="20" />
   <param name="MaximumFileSize" value="100MB" />
   <param name="StaticLogFileName" value="true" />
   <layout type="log4net.Layout.PatternLayout">
    <param name="Header" value="[ Logging start ... ]\r\n" />
    <param name="Footer" value="[ Logging end ... ]\r\n" />
    <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m %n " />
   </layout>
  </appender>
 
  <appender name="MsgsAppender" type="log4net.Appender.RollingFileAppender" >
   <param name="File" value="./Logs/Msgs.log" />
   <param name="AppendToFile" value="true" />
   <param name="MaxSizeRollBackups" value="20" />
   <param name="MaximumFileSize" value="100MB" />
   <param name="StaticLogFileName" value="true" />
   <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%d{HH:mm:ss,fff} %m %n" />
   </layout>
  </appender>
   
  <!-- Setup the root category, add the appenders and set the default level -->
  <root>
   <level value="ERROR" />
   <appender-ref ref="LogFileAppender" />
   <appender-ref ref="WndAppender" />
   <appender-ref ref="TraceAppender" />   
  </root>
  <logger name="ACDPCD.CoreClass">
    <level value="ALL" />
    <appender-ref ref= "MsgsAppender" />
  </logger>
 </log4net>
 
Aaron Scribner
Software Engineer
NEC Unified Solutions, Inc.
Richard Collette

08/03/2006 8:28 PM  
Try Using
 
<filter type="log4net.Filter.LoggerMatchFilter">
    <LoggerToMatch value="ACDPCD.CoreClass"/>
    <AcceptOnMatch value="false"/>
</filter>
 
Within the main file appender.
I haven't specifically used that before but from looking through the SDK it looks appropriate.
 
 
You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > configurable file purging and logging to two files



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement