You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2014/09/11 05:18:33 UTC

[jira] [Comment Edited] (LOG4J2-820) Default interval unit in TimeBasedTriggeringPolicy

    [ https://issues.apache.org/jira/browse/LOG4J2-820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14129569#comment-14129569 ] 

Ralph Goers edited comment on LOG4J2-820 at 9/11/14 3:18 AM:
-------------------------------------------------------------

There is no "default" rollover interval. You control that by the pattern you use in the %d.  

The filePattern you specified above is incorrect. Only a single %d{} is allowed in the pattern.  If that pattern includes HH as the finest granularity then the file will rollover every hour. If it only has 'dd' then it will rollover every day. If it is MM then it will rollover every month.

Your pattern should be "/backup/$$\{yyyy/MM/dd}/module-%d\{yyyy-MM-dd}\-%i.log.gz if you want to roll over every day. if you want to roll over every hour then specify %\{yyyy-MM-dd-HH} instead.  Note that the %i is only going to get incrementedd if the size of your file grows above 2GB during that interval.


was (Author: ralph.goers@dslextreme.com):
There is no "default" rollover interval. You control that by the pattern you use in the %d.  

The filePattern you specified above is incorrect. Only a single %d{} is allowed in the pattern.  If that pattern includes HH as the finest granularity then the file will rollover every hour. If it only has 'dd' then it will rollover every day. If it is MM then it will rollover every month.

Your pattern should be "/backup/$${yyyy/MM/dd}/module-%d{yyyy-MM-dd}-%i.log.gz if you want to roll over every day. if you want to roll over every hour then specify %{yyyy-MM-dd-HH} instead.  Note that the %i is only going to get incrementedd if the size of your file grows above 2GB during that interval.

> Default interval unit in TimeBasedTriggeringPolicy
> --------------------------------------------------
>
>                 Key: LOG4J2-820
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-820
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.0.2
>            Reporter: Hassan Kalaldeh
>
> I just found that default interval type if not given in TimeBasedTriggeringPolicy is day not hour while using RollingFileAppender.
> here is appender I use:
> {code}
> <RollingFile name="DailyRollDfm" fileName="/logs/itms2/dfm.log" filePattern="/backup/%d{yyyy}/%d{MM}/%d{dd}/module-%d{yyyy-MM-dd}-%i.log.gz"
>         append="true" immediateFlush="false">
>       <PatternLayout>
>         <Pattern>%d{ISO8601}: %-5p [%-8t] [%C{1}.%M():%L] - %m%n</Pattern>
>       </PatternLayout>
>       <Policies>
>         <SizeBasedTriggeringPolicy size="2 GB" />
>         <TimeBasedTriggeringPolicy interval="24" modulate="true" />
>         <OnStartupTriggeringPolicy />
>       </Policies>
>    	  <DefaultRolloverStrategy max="100"/>
> </RollingFile>
> {code}
> but the example in http://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender assumes default is in hours not in days.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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