views:

230

answers:

3

Hi All I have the following log4net config

 <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
  <file type="log4net.Util.PatternString" value="Logs/%date{yyyy-MM-dd} Service.log" />   
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <rollingStyle value="Date"/>
  <datePattern value="yyyy-MM-dd"/>
  <maxSizeRollBackups value="100"/>
  <maximumFileSize value="15MB"/>
  <layout type="log4net.Layout.PatternLayout">
   <conversionPattern value="%date %-5level %logger: %message%newline" />
  </layout>
 </appender>

Data will be logged constantly to the log file and rolls OK but i end up having a rolled files like this

2009-12-21 Service.log2009-12-22 (this is what it will write tonight)
2009-12-21 Service.log <-- this being the latest file
2009-12-21 Service.log2009-12-21 <-- last updated 23:59

Does anyone know how i can prevent this

A: 

Mauricio

I want to prevent it from writing the log files like this

2009-12-21 Service.log2009-12-21

it should be
2009-12-21 Service.log
2009-12-22 Service.log
2009-12-23 Service.log

Gaven
A: 

I think the following should be what you need.

Add in the following element within your <appender />.

<staticLogFileName value="true" />
Jeremy Wiebe
Sorry, i still get the same problem
Gaven
+1  A: 

Get rid of the file name and the type in the file element:

<file value="Logs\" />

Then change your datePattern to (note: make sure you escape the letters in 'Service' appropriately, like the g in 'log' is a special format, so you need to escape it with the '\'):

<datePattern value="yyyy-MM-dd Service.lo\g"/>
Ricardo Villamil