You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Tony Payne <tp...@perfectmarket.com> on 2008/10/17 19:33:25 UTC

TimeBasedRollingPolicy with hourly filenames not rolling over at midnight

Here is my configuration:
     <appender name="RA"
class="org.apache.log4j.rolling.RollingFileAppender">
       <param name="Append" value="true"/>
       <rollingPolicy
class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
         <param name="FileNamePattern" value="__LOCAL_VAR__/logs/
%d{yyyy/MM/dd/'race'-yyyyMMddHH}.log.gz"/>
       </rollingPolicy>
       <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d{ISO8601}\t%m%n"/>
       </layout>
     </appender>

This works fine during the day, rolling over at the top of the hour
and compressing the older file. However, at midnight, it stops rolling
over and all subsequent messages go to the last active log name. Is
there something wrong with my configuration?


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: TimeBasedRollingPolicy with hourly filenames not rolling over at midnight

Posted by Curt Arnold <ca...@apache.org>.
On Oct 20, 2008, at 11:59 AM, Tony Payne wrote:

> Has anyone successfully used TimeBasedRollingPolicy? Would you be  
> willing to share a working configuration? If I don't resolve this  
> today, I'll revert to DailyRollingFileAppender and cron jobs to do  
> the compression, a significantly less appetizing approach.
>
> Thanks,
> Tony
>
> On Oct 17, 2008, at 10:33 AM, Tony Payne wrote:
>
>> Here is my configuration:
>>   <appender name="RA"
>> class="org.apache.log4j.rolling.RollingFileAppender">
>>     <param name="Append" value="true"/>
>>     <rollingPolicy
>> class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
>>       <param name="FileNamePattern" value="__LOCAL_VAR__/logs/
>> %d{yyyy/MM/dd/'race'-yyyyMMddHH}.log.gz"/>
>>     </rollingPolicy>
>>     <layout class="org.apache.log4j.PatternLayout">
>>       <param name="ConversionPattern" value="%d{ISO8601}\t%m%n"/>
>>     </layout>
>>   </appender>
>>
>> This works fine during the day, rolling over at the top of the hour
>> and compressing the older file. However, at midnight, it stops  
>> rolling
>> over and all subsequent messages go to the last active log name. Is
>> there something wrong with my configuration?
>


There is a unit test for TimeBasedRollingPolicy that has an associated  
configuration file, if you have the extras companion, look at src/test/ 
resources/org/apache/log4j/rolling/time1.xml.

My suspicion is the problem is with the "yyyy/MM/dd" part of the  
FileNamePattern specification.  At midnight, you would effectively  
change the directory that the log files are stored.  Depending on the  
operating system and JDK, File.renameTo() might fail if you are  
attempting to "rename" a file from one directory to another.  I'm  
guessing that it would be more likely to fail on Windows than on a  
Unix.  org.apache.log4j.rolling.helpers.FileRenameAction does not  
attempt a file copy and delete if File.renameTo fails.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: TimeBasedRollingPolicy with hourly filenames not rolling over at midnight

Posted by Tony Payne <tp...@perfectmarket.com>.
Has anyone successfully used TimeBasedRollingPolicy? Would you be  
willing to share a working configuration? If I don't resolve this  
today, I'll revert to DailyRollingFileAppender and cron jobs to do the  
compression, a significantly less appetizing approach.

Thanks,
Tony

On Oct 17, 2008, at 10:33 AM, Tony Payne wrote:

> Here is my configuration:
>    <appender name="RA"
> class="org.apache.log4j.rolling.RollingFileAppender">
>      <param name="Append" value="true"/>
>      <rollingPolicy
> class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
>        <param name="FileNamePattern" value="__LOCAL_VAR__/logs/
> %d{yyyy/MM/dd/'race'-yyyyMMddHH}.log.gz"/>
>      </rollingPolicy>
>      <layout class="org.apache.log4j.PatternLayout">
>        <param name="ConversionPattern" value="%d{ISO8601}\t%m%n"/>
>      </layout>
>    </appender>
>
> This works fine during the day, rolling over at the top of the hour
> and compressing the older file. However, at midnight, it stops rolling
> over and all subsequent messages go to the last active log name. Is
> there something wrong with my configuration?

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org