Tuesday, 30 August 2011

C# Log4Net configuration for multiple processes with date rolling

This example uses MinimalLock locking Model to allow multiple processes to write to the same file

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="Log\\MyApp.log"/>
  <appendToFile value="true"/>
  <rollingStyle value="Date"/>
  <datePattern value=".yyyyMMdd"/>
  <maxSizeRollBackups value="7"/>
  <staticLogFileName value="true"/>
  <threshold value="INFO"/>
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />                       
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%d [%t] %-5p %c.%M():%L - %m%n"/>
  </layout>
</appender>

Click here for more detailed post about Log4Net configuration in console apps

No comments:

Post a Comment