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 "Hassan Kalaldeh (JIRA)" <ji...@apache.org> on 2014/09/23 11:09:34 UTC

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

     [ 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})

> 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