You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Tiago Cavaleiro (Jira)" <ji...@apache.org> on 2021/06/07 09:34:00 UTC

[jira] [Commented] (LOG4J2-3098) DelectAction malfunctioning when filePattern uses archive path with year and month

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

Tiago Cavaleiro commented on LOG4J2-3098:
-----------------------------------------

Hi, we have updated the configuration to use {{${date:*}}} and enabled the {{status = trace}}.

To give a bit more context, we are using a composite configuration to support multiple appenders and loggers dynamically whilst the JVM is still running.

 

What we noticed is that {{ifAccumulatedFileCount}} doesn't reset to {{0}} and is applied globally to all different appenders.

 

 
{code:java}
09:16:23,540 TRACE IfFileName REJECTED: 'glob:**/token1-*.log' does not match relative path 'token2-20210528-1.log'
09:16:23,540 TRACE Not deleting base=logs/archive, relative=token2-20210528-1.log
09:16:23,540 TRACE IfAccumulatedFileCount ACCEPTED: 2021/05/token3-20210527-1.log count '34' > threshold '30'
09:16:23,540 TRACE IfFileName REJECTED: 'glob:**/token1-*.log' does not match relative path '2021/05/token3-20210527-1.log'
09:16:23,540 TRACE Not deleting base=logs/archive, relative=2021/05/token3-20210527-1.log
09:16:23,540 TRACE IfAccumulatedFileCount ACCEPTED: 2021/05/token1-20210527-1.log count '35' > threshold '30'
09:16:23,540 TRACE IfFileName ACCEPTED: 'glob:**/token1-*.log' matches relative path '2021/05/token1-20210527-1.log'
09:16:23,540 TRACE Deleting logs/archive/2021/05/token1-20210527-1.log
09:16:23,541 TRACE IfAccumulatedFileCount ACCEPTED: token2-20210527-1.log count '36' > threshold '30'
09:16:23,541 TRACE IfFileName REJECTED: 'glob:**/token1-*.log' does not match relative path 'token2-20210527-1.log'
09:16:23,541 TRACE Not deleting base=logs/archive, relative=token2-20210527-1.log
09:16:23,541 TRACE IfAccumulatedFileCount ACCEPTED: 2021/05/token3-20210526-1.log count '37' > threshold '30'
09:16:23,541 TRACE IfFileName REJECTED: 'glob:**/token1-*.log' does not match relative path '2021/05/token3-20210526-1.log'
09:16:23,541 TRACE Not deleting base=logs/archive, relative=2021/05/token3-20210526-1.log
09:16:23,541 TRACE IfAccumulatedFileCount ACCEPTED: token2-20210526-1.log count '38' > threshold '30'
09:16:23,541 TRACE IfFileName REJECTED: 'glob:**/token1-*.log' does not match relative path 'token2-20210526-1.log'
{code}
 

However, having a second thought it probably doesn't make sense to mix both {{ifAccumulatedFileCount}} and {{ifLastModified}} across all different appenders and loggers.

 

 

> DelectAction malfunctioning when filePattern uses archive path with year and month
> ----------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3098
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3098
>             Project: Log4j 2
>          Issue Type: Question
>          Components: Appenders
>    Affects Versions: 2.11.2
>            Reporter: Tiago Cavaleiro
>            Priority: Major
>
> We are running a server side platform using log4j for all logging purposes.
> We have two patterns been used for the logging configuration:
> 1) archive all the log files into a single directory, i.e. /logs/archive
> 2) archive the log files into a directory structure that is organized into /logs/archive/\{year}/\{month}
>  
> For the first scenario described in 1) all is working good, and we can see files been deleted when our strategy actions match. (i.e. delete files over 30d of last modified date or delete files if count is over 30 or accumulated size of 4GB).
>  
> However on the second configuration - 2) - for some weird reason, files are been deleted earlier, i.e. it leaves only 7 files. The accumulated size is way less than 4GB since each file has maximum of 1MB for the running scenarios we have.
>  
> Scenario 1)
> {code:java}
> monitorInterval = 60
> property.baseDir = logs
> property.archiveDir = ${baseDir}/archive
> appender.scenarioOneLog.fileName=${baseDir}/scenarioOne.log
> appender.scenarioOneLog.filePattern=${archiveDir}/scenarioOne-%d{yyyyMMdd}-%i.log
> appender.scenarioOneLog.layout.pattern=%d{yyyy-MM-dd HH\:mm\:ss,SSSZ} [%p] %m%n
> appender.scenarioOneLog.layout.type=PatternLayout
> appender.scenarioOneLog.name=scenarioOneLogFileAppender
> appender.scenarioOneLog.type=RollingFile
> appender.scenarioOneLog.policies.size.size=500MB
> appender.scenarioOneLog.policies.size.type=SizeBasedTriggeringPolicy
> appender.scenarioOneLog.policies.time.interval=1
> appender.scenarioOneLog.policies.time.maxRandomDelay=30
> appender.scenarioOneLog.policies.time.modulate=true
> appender.scenarioOneLog.policies.time.type=TimeBasedTriggeringPolicy
> appender.scenarioOneLog.policies.type=Policies
> appender.scenarioOneLog.strategy.type = DefaultRolloverStrategy
> appender.scenarioOneLog.strategy.max = 30
> appender.scenarioOneLog.strategy.stopCustomActionsOnError = false
> appender.scenarioOneLog.strategy.compressionLevel = 5
> appender.scenarioOneLog.strategy.action.type = Delete
> appender.scenarioOneLog.strategy.action.basepath = ${archiveDir}
> appender.scenarioOneLog.strategy.action.maxDepth = 5
> appender.scenarioOneLog.strategy.action.condition.type = IfFileName
> appender.scenarioOneLog.strategy.action.condition.glob = **/scenarioOne-*.log
> appender.scenarioOneLog.strategy.action.ifAny.type = IfAny
> appender.scenarioOneLog.strategy.action.ifAny.ifLastModified.type = IfLastModified
> appender.scenarioOneLog.strategy.action.ifAny.ifLastModified.age = 30d
> appender.scenarioOneLog.strategy.action.ifAny.ifAccumulatedFileSize.type = IfAccumulatedFileSize
> appender.scenarioOneLog.strategy.action.ifAny.ifAccumulatedFileSize.exceeds = 4 GB
> appender.scenarioOneLog.strategy.action.ifAny.ifAccumulatedFileCount.type = IfAccumulatedFileCount
> appender.scenarioOneLog.strategy.action.ifAny.ifAccumulatedFileCount.exceeds = 30
> logger.scenarioOneLog.name=scenarioOneLogger
> logger.scenarioOneLog.level=info
> logger.scenarioOneLog.additivity=false
> logger.scenarioOneLog.appenderRef.rolling.ref=scenarioOneLogFileAppender
> {code}
>  
> Scenario 2)
> {code:java}
> monitorInterval=60
> property.baseDir=logs
> property.archiveDir=${baseDir}/archive
> appender.scenarioTwoLog.fileName=${baseDir}/scenarioTwo.log
> appender.scenarioTwoLog.filePattern=${archiveDir}/%d{yyyy}/%d{MM}/scenarioTwo-%d{yyyyMMdd}-%i.log
> appender.scenarioTwoLog.layout.pattern=%d{yyyy-MM-dd HH\:mm\:ss,SSSZ} [%p] %m%n
> appender.scenarioTwoLog.layout.type=PatternLayout
> appender.scenarioTwoLog.name=scenarioTwoLogFileAppender
> appender.scenarioTwoLog.type=RollingFile
> appender.scenarioTwoLog.policies.type = Policies
> appender.scenarioTwoLog.policies.time.type = TimeBasedTriggeringPolicy
> appender.scenarioTwoLog.policies.time.interval = 1
> appender.scenarioTwoLog.policies.time.modulate = true
> appender.scenarioTwoLog.policies.time.maxRandomDelay = 30
> appender.scenarioTwoLog.policies.size.type = SizeBasedTriggeringPolicy
> appender.scenarioTwoLog.policies.size.size = 500MB
> appender.scenarioTwoLog.strategy.type = DefaultRolloverStrategy
> appender.scenarioTwoLog.strategy.max = 30
> appender.scenarioTwoLog.strategy.stopCustomActionsOnError = false
> appender.scenarioTwoLog.strategy.compressionLevel = 5
> appender.scenarioTwoLog.strategy.action.type = Delete
> appender.scenarioTwoLog.strategy.action.basepath = ${archiveDir}
> appender.scenarioTwoLog.strategy.action.maxDepth = 5
> appender.scenarioTwoLog.strategy.action.condition.type = IfFileName
> appender.scenarioTwoLog.strategy.action.condition.glob = **/scenarioTwo-*.log
> appender.scenarioTwoLog.strategy.action.ifAny.type = IfAny
> appender.scenarioTwoLog.strategy.action.ifAny.ifLastModified.type = IfLastModified
> appender.scenarioTwoLog.strategy.action.ifAny.ifLastModified.age = 30d
> appender.scenarioTwoLog.strategy.action.ifAny.ifAccumulatedFileSize.type = IfAccumulatedFileSize
> appender.scenarioTwoLog.strategy.action.ifAny.ifAccumulatedFileSize.exceeds = 4 GB
> appender.scenarioTwoLog.strategy.action.ifAny.ifAccumulatedFileCount.type = IfAccumulatedFileCount
> appender.scenarioTwoLog.strategy.action.ifAny.ifAccumulatedFileCount.exceeds = 30
> logger.scenarioTwoLog.name=scenarioTwoLogger
> logger.scenarioTwoLog.level=info
> logger.scenarioTwoLog.additivity=false
> logger.scenarioTwoLog.appenderRef.rolling.ref=scenarioTwoLogFileAppender
> {code}
>  
> Can you please validate to see if we are missing anything, i.e. scenario not supported or is this a limitation or bug when using complex filePattern paths?
>  
> In order to recreate it using status = trace is there any way we can force the rollover programmatically by simulating an end of day? Any ideas without changing the strategy to rotate the log every hour?
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)