Pregunta

  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="c:\temp\mylogfile.txt"/>
    <appendToFile value="true"/>
    <rollingStyle value="Date"/>
    <datePattern value="yyyyMMdd" />
    <maxSizeRollBackups value="5"/>
    <maximumFileSize value="9KB"/>
    <staticLogFileName value="true"/>

How do I set the datePattern value such that a file is created every minute? I have googled and tried different settings and they are not working. please help.

Thanks

¿Fue útil?

Solución

<datePattern value="yyyy-MM-dd HH:mm" /> 

should work but there is a restriction in file name that you can't use : so you have to remove : form file name like this

<datePattern value="yyyy-MM-dd HH mm" /> 

Otros consejos

You need to adjust your datePattern to end in the minute.

<datePattern value="yyyy-MM-dd HH:mm" />

Source: http://geekswithblogs.net/rgupta/archive/2009/03/03/tips-on-using-log4net-rollingfileappender.aspx

RollingFileAppender can roll log files based on size or date or both depending on the setting of the RollingStyle property. When set to Size the log file will be rolled once its size exceeds the MaximumFileSize. When set to Date the log file will be rolled once the date boundary specified in the DatePattern property is crossed.

Your DatePattern is set to roll over every day rather than every minute. You'll need to include the hours and minutes in your datePattern property.

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