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?
 
Here is my config for the RollingFileAppender:
 
  <!-- Rolling Log File appender configuration that all loggers can use -->
  <appender name="AllTypesRollingLogFileAppenderDetail" 
type="log4net.Appender.RollingFileAppender">
   <param name="File" value=".\\Logs\\pos_detail.log" />
   <param name="AppendToFile" value="true" />
   <param name="MaxSizeRollBackups" value="30" />
   <param name="DatePattern" value=".yyyy-MM-dd-tt'.log'" /> 
   <param name="RollingStyle" value="Date" />
   <param name="StaticLogFileName" value="false" />
   <layout type="log4net.Layout.PatternLayout">
    <!-- <param name="Header" value="#TIME THREAD_ID LOG_LEVEL MACHINE USERID 
TRANSID SOURCE METHOD CONTEXT MESSAGE\r\n" /> -->
    <param name="ConversionPattern" value="%d{yyyy'-'MM'-'dd 
HH':'mm':'ss'.'fff}|*|%-5p|*|%t|*|%X{machine}|*|%X{user}|*|%X{trans}|*|%C|*|%M|*|%x|*|%m|**|%n"
 />
   </layout>
   <filter type="log4net.Filter.LevelRangeFilter">
    <param name="LevelMin" value="VERBOSE" />
    <param name="LevelMax" value="ERROR" />
   </filter>
  </appender> 
 
--
 
The DatePattern parameter above is optional and it should default to rolling 
daily, file name of 
"yyyy-MM-dd", but instead rolls over at noon instead of midnight and stomps on 
the existing log file as stated above.  Any ideas?
 
Thanks all,
 
Rob

Reply via email to