Log4net rolling daily filename with date in the file name

JL. picture JL. · Jul 22, 2009 · Viewed 135.2k times · Source

I would like to have files named for example:

dd.mm.yyyy.log

How is this possible with log4net?

Answer

Nonkichi picture Nonkichi · Nov 24, 2011
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
  <file value="logs\" />
  <datePattern value="dd.MM.yyyy'.log'" />
  <staticLogFileName value="false" />
  <appendToFile value="true" />
  <rollingStyle value="Composite" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="5MB" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
  </layout>
</appender>