Discussion:
[jira] [Created] (LOG4J2-820) Default interval unit in TimeBasedTriggeringPolicy
Hassan Kalaldeh (JIRA)
2014-09-10 11:58:28 UTC
Permalink
Hassan Kalaldeh created LOG4J2-820:
--------------------------------------

Summary: 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:
<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>

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)
Ralph Goers (JIRA)
2014-09-11 02:57:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers updated LOG4J2-820:
-------------------------------
Description:
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.

was:
I just found that default interval type if not given in TimeBasedTriggeringPolicy is day not hour while using RollingFileAppender.

here is appender I use:
<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>

but the example in http://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender assumes default is in hours not in days.
Post by Hassan Kalaldeh (JIRA)
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.
{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)
Ralph Goers (JIRA)
2014-09-11 03:17:33 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14129569#comment-14129569 ]

Ralph Goers commented on LOG4J2-820:
------------------------------------

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.
Post by Hassan Kalaldeh (JIRA)
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.
{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)
Ralph Goers (JIRA)
2014-09-11 03:18:33 UTC
Permalink
[ 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: ***@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.
Post by Hassan Kalaldeh (JIRA)
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.
{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)
Ralph Goers (JIRA)
2014-09-11 03:19:33 UTC
Permalink
[ 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:19 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: ***@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.
Post by Hassan Kalaldeh (JIRA)
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.
{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)
Hassan Kalaldeh (JIRA)
2014-09-14 06:11:33 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14133102#comment-14133102 ]

Hassan Kalaldeh commented on LOG4J2-820:
----------------------------------------

I understand your point for the filePattern, but actually I am talking about this part:

{code}<TimeBasedTriggeringPolicy interval="24" modulate="true" />{code}

when I run my application, it gives strange rolling behavior where it give invalid rolled log file name, when I traced the code I found it deals with interval "24" as 24 days which will be used to get rolled file name, BUT in the example from the link I put in task description the example assumes "6" is 6 hours.

referring to the example:
Below is a sample configuration that uses a RollingFileAppender with both the time and size based triggering policies, will create up to 7 archives on the same day (1-7) that are stored in a directory based on the current year and month, and will compress each archive using gzip and will roll every 6 hours when the hour is divisible by 6:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
<Appenders>
<RollingFile name="RollingFile" fileName="logs/app.log"
filePattern="logs/$${date:yyyy-MM}/app-%d{yyyy-MM-dd-HH}-%i.log.gz">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="6" modulate="true"/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
{code}
Post by Hassan Kalaldeh (JIRA)
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.
{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)
Hassan Kalaldeh (JIRA)
2014-09-14 06:53:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14133112#comment-14133112 ]

Hassan Kalaldeh commented on LOG4J2-820:
----------------------------------------

OK I think I got it, I just saw your comment from old ticket LOG4J2-573, you wrote:

"The time-based triggering policy requires a time pattern to determine the frequency to rollover.
In your configuration you have an interval of 12. Is that 12 seconds, minutes, hours or
years? The policy obtains that information by looking at the pattern and using the smallest
time unit in it. Since the policy cannot determine the rollover frequency it is appropriate
for it to throw a Log4j exception."

It would be great if this information can be documented somewhere, thanks Ralph Goers.

BTW, does that mean we don't have the choice to change interval unit without changing file pattern ? for example I want to have a folder of archived logs per day without showing hours (i.e. {code}filePattern="logs/$${date:yyyy-MM-dd}/app-%d{yyyy-MM-dd}-%i.log.gz"{code} , but during the day I want do the archive every 6 hours (so each folder will have four archived files at the end of the day)
Post by Hassan Kalaldeh (JIRA)
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.
{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)
Hassan Kalaldeh (JIRA)
2014-09-23 09:09:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hassan Kalaldeh updated LOG4J2-820:
-----------------------------------
Comment: was deleted

(was: I understand your point for the filePattern, but actually I am talking about this part:

{code}<TimeBasedTriggeringPolicy interval="24" modulate="true" />{code}

when I run my application, it gives strange rolling behavior where it give invalid rolled log file name, when I traced the code I found it deals with interval "24" as 24 days which will be used to get rolled file name, BUT in the example from the link I put in task description the example assumes "6" is 6 hours.

referring to the example:
Below is a sample configuration that uses a RollingFileAppender with both the time and size based triggering policies, will create up to 7 archives on the same day (1-7) that are stored in a directory based on the current year and month, and will compress each archive using gzip and will roll every 6 hours when the hour is divisible by 6:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
<Appenders>
<RollingFile name="RollingFile" fileName="logs/app.log"
filePattern="logs/$${date:yyyy-MM}/app-%d{yyyy-MM-dd-HH}-%i.log.gz">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="6" modulate="true"/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
{code})
Post by Hassan Kalaldeh (JIRA)
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.
{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)
Hassan Kalaldeh (JIRA)
2014-09-23 09:10:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hassan Kalaldeh resolved LOG4J2-820.
------------------------------------
Resolution: Done
Post by Hassan Kalaldeh (JIRA)
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.
{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)

Loading...