[jira] [Commented] (LOG4J2-3569) Incorrect logic/code or comment for AbstractFilterable.isFiltered method

2022-08-10 Thread Ralph Goers (Jira)


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

Ralph Goers commented on LOG4J2-3569:
-

Welcome to the wonderful world of open source!

I think the comment is just wrong. It should read "Return true if the logEvent 
should be excluded". 

I don't see any inconsistency in how AppenderControl or SmtpAppender are 
working. SmtpAppender is a bit strange in that excluded events are written to a 
buffer so that when an event that is NOT filtered is received all the events in 
the buffer are included as well.



> Incorrect logic/code or comment for AbstractFilterable.isFiltered method 
> -
>
> Key: LOG4J2-3569
> URL: https://issues.apache.org/jira/browse/LOG4J2-3569
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Filters
>Affects Versions: 2.17.2
> Environment: All Enviroments
>Reporter: Pawandeep Singh Bhatti
>Priority: Blocker
>
> Hello,
>  
> This is my first issue ever for an open source project.
>  
> I was going through Log4j2 source code and stumbled upon following method:
> {code:java}
> /**
>  * Determine if the LogEvent should be processed or ignored.
>  * @param event The LogEvent.
>  * @return true if the LogEvent should be processed.
>  */
> @Override
> public boolean isFiltered(final LogEvent event) {
> return filter != null && filter.filter(event) == Filter.Result.DENY;
> } {code}
>  
>  
> Here is a link to the code on github:
> [Link|https://github.com/apache/logging-log4j2/blob/40214e87c46c9534abcd8c5abf2b154f4c561002/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/AbstractFilterable.java#L153]
> Either the java doc is incorrect - which says @return true if the LogEvent 
> should be processed.
> Or this line is wrong,
> return filter != null && filter.filter(event) == Filter.Result.DENY;
>  
> Please check.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior

2022-08-10 Thread Wolff Bock von Wuelfingen (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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] [Updated] (LOG4J2-2148) CronTriggeringPolicy renaming behavior

2022-08-10 Thread Wolff Bock von Wuelfingen (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Wolff Bock von Wuelfingen updated LOG4J2-2148:
--
Attachment: FileExtension.java
FixedCronTriggeringPolicy.java
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

2022-08-10 Thread Wolff Bock von Wuelfingen (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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 fr

[jira] [Updated] (LOG4J2-3570) java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ServiceLoaderUtil

2022-08-10 Thread Vivek (Jira)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-3570?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Vivek updated LOG4J2-3570:
--
Priority: Blocker  (was: Major)

> java.lang.NoClassDefFoundError: 
> org/apache/logging/log4j/util/ServiceLoaderUtil
> ---
>
> Key: LOG4J2-3570
> URL: https://issues.apache.org/jira/browse/LOG4J2-3570
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.18.0
>Reporter: Vivek
>Priority: Blocker
> Fix For: 2.17.2
>
>
> Hello,
> Earlier I am using the below libraries in the Java Gradle project, and it 
> works fine:
> {color:#4c9aff}implementation 'org.slf4j:slf4j-api:1.7.36'{color}
> {color:#4c9aff}implementation 'org.slf4j:slf4j-log4j12:1.7.36'{color}
> {color:#4c9aff}implementation 
> 'org.apache.logging.log4j:log4j-core:2.17.2'{color}
> {color:#4c9aff}implementation 'log4j:apache-log4j-extras:1.3.1-mapr'{color}
> But as soon as I upgrade to{color:#4c9aff} 
> 'org.apache.logging.log4j:log4j-core:2.18.0'{color}, I am starting to get 
> error.
>  
> Thank you



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (LOG4J2-3570) java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ServiceLoaderUtil

2022-08-10 Thread Vivek (Jira)
Vivek created LOG4J2-3570:
-

 Summary: java.lang.NoClassDefFoundError: 
org/apache/logging/log4j/util/ServiceLoaderUtil
 Key: LOG4J2-3570
 URL: https://issues.apache.org/jira/browse/LOG4J2-3570
 Project: Log4j 2
  Issue Type: Bug
  Components: Core
Affects Versions: 2.18.0
Reporter: Vivek
 Fix For: 2.17.2


Hello,

Earlier I am using the below libraries in the Java Gradle project, and it works 
fine:

{color:#4c9aff}implementation 'org.slf4j:slf4j-api:1.7.36'{color}
{color:#4c9aff}implementation 'org.slf4j:slf4j-log4j12:1.7.36'{color}
{color:#4c9aff}implementation 
'org.apache.logging.log4j:log4j-core:2.17.2'{color}
{color:#4c9aff}implementation 'log4j:apache-log4j-extras:1.3.1-mapr'{color}

But as soon as I upgrade to{color:#4c9aff} 
'org.apache.logging.log4j:log4j-core:2.18.0'{color}, I am starting to get error.

 

Thank you



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (LOG4J2-2148) CronTriggeringPolicy renaming behavior

2022-08-10 Thread Wolff Bock von Wuelfingen (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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

2022-08-10 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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

2022-08-10 Thread Wolff Bock von Wuelfingen (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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

2022-08-10 Thread Wolff Bock von Wuelfingen (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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

[jira] [Commented] (LOG4J2-3569) Incorrect logic/code or comment for AbstractFilterable.isFiltered method

2022-08-10 Thread Pawandeep Singh Bhatti (Jira)


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

Pawandeep Singh Bhatti commented on LOG4J2-3569:


 

I see contradictory implementations at multiple places in code:


1.

org.apache.logging.log4j.core.config.AppenderControl#isFilteredByAppenderControl

private boolean isFilteredByAppenderControl(final LogEvent event) {
    final Filter filter = getFilter();
    return filter != null && Filter.Result.DENY == filter.filter(event);
}

 

2.
org.apache.logging.log4j.core.appender.SmtpAppender#isFiltered

/**
* Capture all events in CyclicBuffer.
* @param event The Log event.
* @return true if the event should be filtered.
*/
@Override
public boolean isFiltered(final LogEvent event) {
   final boolean filtered = super.isFiltered(event);
   if (filtered) { 
        

          // SHOULD we add it to Cyclic Buffer if it is supposed to be filtered 
out ?

         manager.add(event);
    }
    return filtered;
}

 

> Incorrect logic/code or comment for AbstractFilterable.isFiltered method 
> -
>
> Key: LOG4J2-3569
> URL: https://issues.apache.org/jira/browse/LOG4J2-3569
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Filters
>Affects Versions: 2.17.2
> Environment: All Enviroments
>Reporter: Pawandeep Singh Bhatti
>Priority: Blocker
>
> Hello,
>  
> This is my first issue ever for an open source project.
>  
> I was going through Log4j2 source code and stumbled upon following method:
> {code:java}
> /**
>  * Determine if the LogEvent should be processed or ignored.
>  * @param event The LogEvent.
>  * @return true if the LogEvent should be processed.
>  */
> @Override
> public boolean isFiltered(final LogEvent event) {
> return filter != null && filter.filter(event) == Filter.Result.DENY;
> } {code}
>  
>  
> Here is a link to the code on github:
> [Link|https://github.com/apache/logging-log4j2/blob/40214e87c46c9534abcd8c5abf2b154f4c561002/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/AbstractFilterable.java#L153]
> Either the java doc is incorrect - which says @return true if the LogEvent 
> should be processed.
> Or this line is wrong,
> return filter != null && filter.filter(event) == Filter.Result.DENY;
>  
> Please check.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (LOG4J2-3569) Incorrect logic/code or comment for AbstractFilterable.isFiltered method

2022-08-10 Thread Pawandeep Singh Bhatti (Jira)
Pawandeep Singh Bhatti created LOG4J2-3569:
--

 Summary: Incorrect logic/code or comment for 
AbstractFilterable.isFiltered method 
 Key: LOG4J2-3569
 URL: https://issues.apache.org/jira/browse/LOG4J2-3569
 Project: Log4j 2
  Issue Type: Bug
  Components: Filters
Affects Versions: 2.17.2
 Environment: All Enviroments
Reporter: Pawandeep Singh Bhatti


Hello,

 

This is my first issue ever for an open source project.

 

I was going through Log4j2 source code and stumbled upon following method:
{code:java}
/**
 * Determine if the LogEvent should be processed or ignored.
 * @param event The LogEvent.
 * @return true if the LogEvent should be processed.
 */
@Override
public boolean isFiltered(final LogEvent event) {
return filter != null && filter.filter(event) == Filter.Result.DENY;
} {code}
 

 

Here is a link to the code on github:
[Link|https://github.com/apache/logging-log4j2/blob/40214e87c46c9534abcd8c5abf2b154f4c561002/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/AbstractFilterable.java#L153]

Either the java doc is incorrect - which says @return true if the LogEvent 
should be processed.



Or this line is wrong,

return filter != null && filter.filter(event) == Filter.Result.DENY;

 

Please check.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)