Pregunta

I have implemented RollingFileAppender to log my ASP errors and it works fine.
Now I need to change the file names based on the date value. Currently my log file name is MyLog.log, it's max size is 1 MB and maxBackup is 10. Now I want my log files with date like MyLog_2011-12-29 for each day. I tried the below settings, but it's not appending the date value to the file name and it just creates the file as MyLog. Any suggestions?

EDITED

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="C:\\xxx\\ASPErrors\\LogFile"/>     
  <staticLogFileName value="false"/>
  <appendToFile value="true"/>
  <rollingStyle value="Composite"/>
  <eventId value="5" />
  <eventCategory value="ErrorLogging" />
  <datePattern value="_yyyy-MM-dd'.log'" />
  <maxSizeRollBackups value="10"/>
  <maximumFileSize value="1MB"/>  
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n"/>
  </layout>
</appender>
¿Fue útil?

Solución

I think the problem is you have the "staticLogFileName" property twice in the config, the second one is overwriting the first.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top