[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17578551#comment-17578551 ] Wolff Bock von Wuelfingen commented on LOG4J2-2148: --- >The main problem here is that, as you noticed, all these strategies and >policies are somewhat co-dependent. Sometimes it feels like playing >whack-a-mole as when one bug is fixed another pops up somewhere else. Hehe exactly. I guess then, if i find a solution (i have something in mind) which is a bit more general, i should create a new issue for the structural problem and then do the PR against that, fixing the policies along the way. And of course, will write tests against it :) > 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 >Priority: Major > Attachments: FileExtension.java, FixedCronTriggeringPolicy.java, > FixedDefaultRolloverStrategy.java, FixedOnStartupTriggeringPolicy.java > > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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 (v8.20.10#820010)
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17578546#comment-17578546 ] Ralph Goers commented on LOG4J2-2148: - The best bet is to create a pull request at GitHub. Then ensure there is a unit test that covers this issue and that it, and all the other unit tests, work correctly. The main problem here is that, as you noticed, all these strategies and policies are somewhat co-dependent. Sometimes it feels like playing whack-a-mole as when one bug is fixed another pops up somewhere else. > 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 >Priority: Major > Attachments: FileExtension.java, FixedCronTriggeringPolicy.java, > FixedDefaultRolloverStrategy.java, FixedOnStartupTriggeringPolicy.java > > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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 (v8.20.10#820010)
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17578317#comment-17578317 ] Wolff Bock von Wuelfingen commented on LOG4J2-2148: --- [~ggregory] since i have no experience with how apache / log4j handles problems on this scope, what should i do now? Since this is kind of multiple problems all originally caused by an architectural problem. > 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 >Priority: Major > Attachments: FileExtension.java, FixedCronTriggeringPolicy.java, > FixedDefaultRolloverStrategy.java, FixedOnStartupTriggeringPolicy.java > > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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 (v8.20.10#820010)
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17578085#comment-17578085 ] Wolff Bock von Wuelfingen commented on LOG4J2-2148: --- I ultimately got alteast cron and onstartup to work correctly with eachother by implementing my customized version of them and DefaultRolloverStrategy (aswell as FileExtension, for the PS mentioned above). But i think something should definitely be straightened / redesigned here. I attached the classes for the curious. [^FileExtension.java] !FixedCronTriggeringPolicy.java|width=7,height=7,align=absmiddle! [^FixedDefaultRolloverStrategy.java] [^FixedOnStartupTriggeringPolicy.java] > 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 >Priority: Major > Attachments: FileExtension.java, FixedCronTriggeringPolicy.java, > FixedDefaultRolloverStrategy.java, FixedOnStartupTriggeringPolicy.java > > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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 (v8.20.10#820010)
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17578079#comment-17578079 ] Wolff Bock von Wuelfingen commented on LOG4J2-2148: --- I found several issues which are all somewhat related to the problem. Inside CronTriggeringPolicy there are several calls to the PatternProcessor, which override its "normal" keeping track of timestamps. And another call inside its custom rollover() method also forces a timestamp on the manager, which in turn does the same - applying that false timestamp to the PatternProcessor. And there also is a bug in OnStartupTriggeringPolicy: It never sets the current file time for the PatternProcessor. Meaning if any other policies depend upon that value set, they will fail. And also PatternProcessor.getNextTime() - which according to it's javadoc should only return the next potential rollover time) - just overwrites prevFileTime with nextFileTime?! That can't be correct? Honestly it kind of seems like all the policies (i looked at startup, timebased, cron, sizebased) are just overwriting the timestamps of PatternProcessor so that they work if only they themselves are used. Which i guess is because DefaultRolloverStrategy uses {code:java} PatternProcessor.formatFileName((final StrSubstitutor subst, final StringBuilder buf, final Object obj)){code} and not {code:java} PatternProcessor.formatFileName(final StrSubstitutor subst, final StringBuilder buf, final boolean useCurrentTime, final Object obj) { {code} This means that, even if the timestamps would be set correctly by the policies, the used file name for the to-be-archived file would contain the timestamp of the *previously* archived file and thus overwrite it. I think maybe RollingFileManager should actually do some managing and update the timestamps to be used by the PatternProcessor, so that the policies don't have to manage that. PS: org.apache.logging.log4j.core.appender.rolling.FileExtension has several methods on default visibility, which is problematic if one wants to extend AbstractRolloverStrategy. > 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 >Priority: Major > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. It looks like the first non-fixed value from "shedule" >
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17577976#comment-17577976 ] Wolff Bock von Wuelfingen commented on LOG4J2-2148: --- Yeap, i am. > 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 >Priority: Major > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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 (v8.20.10#820010)
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17577975#comment-17577975 ] Gary D. Gregory commented on LOG4J2-2148: - Hi [~wlfbck] Are you using 2.18.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 >Priority: Major > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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 (v8.20.10#820010)
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17577959#comment-17577959 ] Wolff Bock von Wuelfingen commented on LOG4J2-2148: --- Oh i just noticed, CronTriggeringPolicy also inserted the day-of-month from yesterday. So yeah, definitely bugged. > 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 >Priority: Major > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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 (v8.20.10#820010)
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17577957#comment-17577957 ] Wolff Bock von Wuelfingen commented on LOG4J2-2148: --- I'm pretty sure this problem is still present in the latest log4j2 version. I used the following RollingFileAppender: {code:java} ${LOG_DIR}system.log ${LOG_DIR}system%d{-MM-dd HH.mm.ss}.log.zip {code} I then started my program 3 times before 13.40, the last launch i let run past 13.40. Here are the created files at 13.50: ||file name||comment||first timestamp||last timestamp|| |system.log|The current file|13:40:51|13:51:26| |system2022-08-09 13.40.00.log.zip|Triggered by CronTriggeringPolicy|13:35:33|13:39:51| |system2022-08-10 13.33.15.log.zip|Triggered by OnStartupTriggeringPolicy I just stopped the program.|13:33:15|13:34:15| |system2022-08-10 13.32.33.log.zip|Triggered by OnStartupTriggeringPolicy I just stopped the program.|13:32:33|13:32:49| So obviously there is a discrepency in behavior here. It seems to me that OnStartupTriggeringPolicy uses the timestamp at the start of the log file which it will rollover. On the other hand CronTriggeringPolicy seems to use exactly the fixed the numbers from "schedule" and only inserts the placeholders ( * ). Atleast personally i expected CronTriggeringPolicy to use the same behavior as OnStartupTriggeringPolicy and use the timestamp at the start of the log file. Note though that my experience with log4j2 is somewhat limited, so i don't know how the other policies behave. > 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 >Priority: Major > > 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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.
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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)
[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior
[ https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16287630#comment-16287630 ] Gary Gregory commented on LOG4J2-2148: -- I would start by using the current version: 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{MMdd-HHmmssSSS}.log.gz2" > I have the followig Log4j2 configuration to achieve these requirements: > {noformat} > > > > logs/l4j2_ > logs/bck/l4j2_ > log.bz2 > MMdd-HHmmssSSS > %d %-5p [%t] - > %m%n > > > >fileName="${filePath}cpm-javascript.log" > > filePattern="${fileBackupPath}cpm-javascript-%d{${fileDatePattern}}.${fileSuffix}" > createOnDemand="true"> > > > > > > > > >glob="l4j2_cpm-javascript*.${fileSuffix}"> > >exceeds="200 MB" /> >exceeds="25" /> > > > > > > > >additivity="false"> > > > > > {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-2017-235215000.log.gz2. > - 2017/11/12 00:00:00 Rollover for the file using "CronTriggeringPolicy" -> > creates new file: l4j2_cpm-javascript-2017-0.log.gz2. > And this is the problem, because you have the file named "2017-0" > and it contains log records from the interval from 2017-235215000 to > 2017-23595. 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 > ...2017-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)