开发者

unique log file with log4net

hi i'm using log4net for logging my website. Every day a new file is created like "filename.log24-06-2009"

this is the code in the web.config file:

 <log4net>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="App_Data\Missioni.log" />
      <appendToFile value="true" />
      <rollingStyle value="Composite" />
      <!--<datePattern value="yyyy-MM-dd" />-->
      <maxSizeRollBackups value="5" />
开发者_高级运维      <maximumFileSize value="5MB" />
      <layout type="log4net.Layout.PatternLayout">
        <header value="[Header]&#xA;" />
        <footer value="[Footer]&#xA;" />
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>
  </log4net>

How can i do for use a unique log file?

thanks


The question' a bit unclear, so please comment if I'm off. If you want to change how the files are created, uncomment the datePattern block and you can specify the file name layout, for example if you wanted the log to change monthly:

<datePattern value="yyyy-MM" />

When the pattern changes (midnight with the standard datePattern) a new file is created, change the pattern to so it only rolls to a new file when you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜