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

Remko Popma commented on LOG4J2-385:
------------------------------------

Cron... to be honest, I know it is a standard, but I really dislike the 
format... It "makes me think", every time I look at a crontab. I can't just 
"grok" what it says, I always have to think twice about it...

However, the [predefined 
values|http://en.wikipedia.org/wiki/Cron#Predefined_scheduling_definitions] 
like {{@hourly}}, {{@weekly}} are very nice. I would like to be able to use 
those... 

At the moment the {{"$\{yyyy-W}"}} pattern does double duty: it determine the 
rollover frequency, and it also lets the user determine (to some limited 
degree) how the resulting file will be named after the rollover. 

Instead of asking the user to specify a pattern for the rename, we could use a 
fixed renaming rule:
* {{filepattern="/logs/mylog_$\{@yearly}.log.gz"}} -> rollover once a year at 
midnight in the morning of January 1. Rename format is fixed {{"yyyy"}}. E.g. 
on Jan 1, 2014, the old log file is renamed to {{/logs/mylog_2013.log.gz}}
* {{filepattern="/logs/mylog_$\{@monthly}.log.gz"}} -> rollover once a month at 
midnight in the morning of the first day of the month. Rename format is fixed 
{{"yyyy-MM"}}. E.g. on Feb 1, 2014, the old log file is renamed to 
{{/logs/mylog_2013-01.log.gz}}
* {{filepattern="/logs/mylog_$\{@weekly}.log.gz"}} -> once a week at midnight 
the (locale-dependent) first day of the week. Rename format is fixed 
{{"yyyy-MM-dd"}}. E.g. on Feb 2, 2014, the old log file is renamed to 
{{/logs/mylog_2013-01-26.log.gz}}
* {{filepattern="/logs/mylog_$\{@daily}.log.gz"}} -> once a day at midnight. 
Rename format is fixed {{"yyyy-MM-dd"}}. E.g. on Feb 1, 2014, the old log file 
is renamed to {{/logs/mylog_2013-01-31.log.gz}}
* {{filepattern="/logs/mylog_$\{@hourly}.log.gz"}} -> once an hour at the 
beginning of the hour. Rename format is fixed {{"yyyy-MM-dd_HH"}}. E.g. on Feb 
1, 2014, 10:00 the old log file is renamed to 
{{/logs/mylog_2013-02-01_09.log.gz}}
* {{filepattern="/logs/mylog_$\{@minutely}.log.gz"}} -> once a minute at the 
beginning of the minute. Rename format is fixed {{"yyyy-MM-dd_HH-mm"}}. E.g. on 
Feb 1, 2014, 10:03 the old log file is renamed to 
{{/logs/mylog_2013-02-01_10-02.log.gz}}

Thoughts?

I would *not* like to ask users to use this type of cron format below:
{code}
 #  *  *  *  *  *  command to execute
 # ┬ ┬ ┬ ┬ ┬
 # │ │ │ │ │
 # │ │ │ │ │
 # │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use 
names; 7 is Sunday, the same as 0)
 # │ │ │ └────────── month (1 - 12)
 # │ │ └─────────────── day of month (1 - 31)
 # │ └──────────────────── hour (0 - 23)
 # └───────────────────────── min (0 - 59)
{code}


> Unable to roll log files monthly
> --------------------------------
>
>                 Key: LOG4J2-385
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-385
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.0-beta8
>         Environment: Java 1.7.0_25, Windows 7 64bit, IntelliJ IDEA 12 Ultimate
>            Reporter: Ace Funk
>            Assignee: Remko Popma
>         Attachments: LOG4J2-385.patch
>
>
> Attempting to use FastRollingFile appender and configure log file rollover to 
> occur monthly.  When {{filePattern="logs/app-%d\{yyyy-MM}.log.gz"}} is used, 
> at application startup an archive file is created immediately 
> (app-2013-01.log.gz) even if no log previously existed.  A log file is 
> created, but only a single entry is made into the log.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to