You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (Jira)" <ji...@apache.org> on 2021/05/30 17:35: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=17354089#comment-17354089 ] 

Ralph Goers commented on LOG4J2-3098:
-------------------------------------

Log4j uses the %d pattern in the filePattern to determine when a rollover should occur. Therefore it is invalid to have more than one %d in the file pattern. You would need to use $date{} for the directories instead.

> 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
>    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)