problem with rolling by date behavior of RollingFileAppender

"Robert Freas" <[email protected]> Tue, 14 Dec 2004 15:32:28 -0600
Newsgroups gmane.comp.windows.dotnet.log4net.user
Message-ID <E2F6921BCFFC274D93E92D1EE98C1D2F0476B3@Claritymail.clarityinternal.net>
I am using the RollingFileAppender and have configured it to roll by =
date without specifying a DatePattern parameter.  When I did that, it =
would log properly from 12:00AM midnight to 11:59AM, but the moment it =
hit 12:00PM noon, it would roll over on top of itself and start =
rewriting in the same file--thereby losing all logging from 12:00AM - =
11:59AM.  To work around this, I added a DatePattern parameter value and =
included "tt" so that it names the log files with the "AM" and "PM" text =
at the end, so as not to overwrite the previous 12 hours of logging.  By =
default, I thought the RollingFileAppender rolled daily at =
midnight--what is going on?  Why is this necessary?
=20
Here is my config for the RollingFileAppender:
=20
  <!-- Rolling Log File appender configuration that all loggers can use =
-->
  <appender name=3D"AllTypesRollingLogFileAppenderDetail" =
type=3D"log4net.Appender.RollingFileAppender">
   <param name=3D"File" value=3D".\\Logs\\pos_detail.log" />
   <param name=3D"AppendToFile" value=3D"true" />
   <param name=3D"MaxSizeRollBackups" value=3D"30" />
   <param name=3D"DatePattern" value=3D".yyyy-MM-dd-tt'.log'" />=20
   <param name=3D"RollingStyle" value=3D"Date" />
   <param name=3D"StaticLogFileName" value=3D"false" />
   <layout type=3D"log4net.Layout.PatternLayout">
    <!-- <param name=3D"Header" value=3D"#TIME THREAD_ID LOG_LEVEL =
MACHINE USERID TRANSID SOURCE METHOD CONTEXT MESSAGE\r\n" /> -->
    <param name=3D"ConversionPattern" value=3D"%d{yyyy'-'MM'-'dd =
HH':'mm':'ss'.'fff}|*|%-5p|*|%t|*|%X{machine}|*|%X{user}|*|%X{trans}|*|%C=
|*|%M|*|%x|*|%m|**|%n" />
   </layout>
   <filter type=3D"log4net.Filter.LevelRangeFilter">
    <param name=3D"LevelMin" value=3D"VERBOSE" />
    <param name=3D"LevelMax" value=3D"ERROR" />
   </filter>
  </appender>=20
=20
--
=20
The DatePattern parameter above is optional and it should default to =
rolling daily, file name of=20
"yyyy-MM-dd", but instead rolls over at noon instead of midnight and =
stomps on the existing log file as stated above.  Any ideas?
=20
Thanks all,
=20
Rob


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/