views:

126

answers:

1

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

+1  A: 

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.

Nick Craver
if i uncomment the tag datepattern the filename doesn't change
Luca Romagnoli
@Luca - Can you describe more what you want? You want a file per *something*, a different date pattern, monthly logs, something else entirely?
Nick Craver
i don't want a log file per day. i want a log file per month
Luca Romagnoli
@Luca- Sorry I missed it, also adjust to this: `<rollingStyle value="Date" />`
Nick Craver