[
https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16288919#comment-16288919
]
Petr Valenta commented on LOG4J2-2148:
--------------------------------------
Still same behaviour with 2.10.0.
> CronTriggeringPolicy renaming behavior
> --------------------------------------
>
> Key: LOG4J2-2148
> URL: https://issues.apache.org/jira/browse/LOG4J2-2148
> Project: Log4j 2
> Issue Type: Question
> Components: Appenders
> Affects Versions: 2.8
> Reporter: Petr Valenta
>
> Hi.
> I tried CronTriggeringPolicy(version 2.8) for save daily log files at
> midnight.
> My requirementare as follows:
> 1) Log file should be of max size 30MB, beyond which new log file should be
> generated.
> 2) Every midnight log file should be rolled over (to "bck" subfolder).
> 3) The following filePattern for the rollovered log files:
> "l4j2_cpm-javascript-%d{yyyyMMdd-HHmmssSSS}.log.gz2"
> I have the followig Log4j2 configuration to achieve these requirements:
> {noformat}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="debug" monitorInterval="10">
> <Properties>
> <Property name="filePath">logs/l4j2_</Property>
> <Property name="fileBackupPath">logs/bck/l4j2_</Property>
> <Property name="fileSuffix">log.bz2</Property>
> <Property name="fileDatePattern">yyyyMMdd-HHmmssSSS</Property>
> <Property name="basicPatternLayout">%d %-5p [%t] -
> %m%n</Property>
> </Properties>
> <Appenders>
> <!-- CPM - javascript log -->
> <RollingFile name="CPMCommonJavaScriptAppender"
> fileName="${filePath}cpm-javascript.log"
>
> filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}"
> createOnDemand="true">
> <PatternLayout pattern="${basicPatternLayout}" />
> <Policies>
> <OnStartupTriggeringPolicy />
> <CronTriggeringPolicy schedule="0 0 0 * * ?"/>
> <SizeBasedTriggeringPolicy size="30MB" />
> </Policies>
> <DefaultRolloverStrategy>
> <Delete basePath="logs/bck" maxDepth="1">
> <IfFileName
> glob="l4j2_cpm-javascript*.${fileSuffix}">
> <IfAny>
> <IfAccumulatedFileSize
> exceeds="200 MB" />
> <IfAccumulatedFileCount
> exceeds="25" />
> </IfAny>
> </IfFileName>
> </Delete>
> </DefaultRolloverStrategy>
> </RollingFile>
> </Appenders>
> <Loggers>
> <Logger name="cpm.common.javascript" level="debug"
> additivity="false">
> <AppenderRef ref="CPMCommonJavaScriptAppender" />
> </Logger>
> </Loggers>
> </Configuration>
> {noformat}
> But I have problem with file name in case that "_CronTriggeringPolicy_" is
> used. For example today is 2017/11/11:
> - 2017/11/11 23:52:15 Rollover for the file using "SizeBasedTriggeringPolicy"
> -> creates new file: l4j2_cpm-javascript-20171111-235215000.log.gz2.
> - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" ->
> creates new file: l4j2_cpm-javascript-20171111-000000000.log.gz2.
> And this is the problem, because you have the file named "20171111-000000000"
> and it contains log records from the interval from 20171111-235215000 to
> 20171111-235959999. It looks like the first non-fixed value from "shedule"
> settings (for CronTriggeringPolicy) is decreased by 1. You can observe the
> same behaviour for rollover per minute -> schedule="0 0/1 * * * ?". In this
> case the log file generated for example at 2017/11/11 10:10:00 will be named
> ...20171111-100900..., etc.
> I have tried various combinations of filePattern values, policies and
> schedule parameter (for CronTriggeringPolicy) but have not been able to
> achieve correct file name. Please let me know where I am going wrong. Thanks
> for your help, I'm very appreciated it.
> Regards
> Petr
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)