Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Abandoned
-
2.10.0
-
None
-
None
-
- OS: windows10 x64
- JDK:1.8.0.101 x64
- log4j-api:2.10.0
- log4j-core:2.10.0
- logger use "Data"
- Interval 100 milliseconds to insert a piece of data
log4j2.xml:
<configuration status="TRACE" monitorInterval="10" > <properties> <property name="LOG_HOME">.</property> </properties> <appenders> <Console name="STDOUT" target="SYSTEM_OUT"> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level - %msg%n"/> </Console> <RollingFile name="Datalog" filePattern="./logs/$${date:yyyy-MM}/warn_%d{yyyyMMddHH}.log"> <!--<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>--> <PatternLayout pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/> <Policies> <TimeBasedTriggeringPolicy modulate="true" interval="1"/> <!--<SizeBasedTriggeringPolicy size="100 MB"/>--> </Policies> <DirectWriteRolloverStrategy> <Delete basePath="./logs/" maxDepth="2"> <IfFileName glob="*/warn_*.log" /> <IfLastModified age="6M"/> </Delete> </DirectWriteRolloverStrategy> </RollingFile> </appenders> <loggers> <Logger name="Data" level="info" additivity="false"> <AppenderRef ref="Datalog"/> </Logger> <Root level="info"> <AppenderRef ref="STDOUT"/> </Root> </loggers> </configuration>
OS: windows10 x64 JDK:1.8.0.101 x64 log4j-api:2.10.0 log4j-core:2.10.0 logger use " Data " Interval 100 milliseconds to insert a piece of data log4j2.xml: <configuration status= "TRACE" monitorInterval= "10" > <properties> <property name= "LOG_HOME" >.</property> </properties> <appenders> <Console name= "STDOUT" target= "SYSTEM_OUT" > <PatternLayout pattern= "%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level - %msg%n" /> </Console> <RollingFile name= "Datalog" filePattern= "./logs/$${date:yyyy-MM}/warn_%d{yyyyMMddHH}.log" > <!--<ThresholdFilter level= "info" onMatch= "ACCEPT" onMismatch= "DENY" />--> <PatternLayout pattern= "[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n" /> <Policies> <TimeBasedTriggeringPolicy modulate= " true " interval= "1" /> <!--<SizeBasedTriggeringPolicy size= "100 MB" />--> </Policies> <DirectWriteRolloverStrategy> <Delete basePath= "./logs/" maxDepth= "2" > <IfFileName glob= "*/warn_*.log" /> <IfLastModified age= "6M" /> </Delete> </DirectWriteRolloverStrategy> </RollingFile> </appenders> <loggers> <Logger name= "Data" level= "info" additivity= " false " > <AppenderRef ref= "Datalog" /> </Logger> <Root level= "info" > <AppenderRef ref= "STDOUT" /> </Root> </loggers> </configuration>
Description
PatternProcessor.currentFileTime always 0L causes always use PatternProcessor.prevFileTiem as rolling filePattern name.
2018-04-08 10:20:46,504 main DEBUG Now writing to ./logs/2018-04/warn_2018040810.log at 2018-04-08T10:20:46.504+0800 2018-04-08 11:00:00,079 main DEBUG Now writing to ./logs/2018-04/warn_2018040810.log at 2018-04-08T11:00:00.079+0800 2018-04-08 12:00:00,284 main DEBUG Now writing to ./logs/2018-04/warn_2018040811.log at 2018-04-08T12:00:00.284+0800
stack:
formatFileName:269, PatternProcessor (org.apache.logging.log4j.core.appender.rolling) getCurrentFileName:318, DirectWriteRolloverStrategy (org.apache.logging.log4j.core.appender.rolling) getFileName:200, RollingFileManager (org.apache.logging.log4j.core.appender.rolling) createOutputStream:186, FileManager (org.apache.logging.log4j.core.appender) createFileAfterRollover:324, RollingFileManager (org.apache.logging.log4j.core.appender.rolling) rollover:316, RollingFileManager (org.apache.logging.log4j.core.appender.rolling) checkRollover:252, RollingFileManager (org.apache.logging.log4j.core.appender.rolling) append:307, RollingFileAppender (org.apache.logging.log4j.core.appender) tryCallAppender:156, AppenderControl (org.apache.logging.log4j.core.config) callAppender0:129, AppenderControl (org.apache.logging.log4j.core.config) callAppenderPreventRecursion:120, AppenderControl (org.apache.logging.log4j.core.config) callAppender:84, AppenderControl (org.apache.logging.log4j.core.config) callAppenders:448, LoggerConfig (org.apache.logging.log4j.core.config) processLogEvent:433, LoggerConfig (org.apache.logging.log4j.core.config) log:417, LoggerConfig (org.apache.logging.log4j.core.config) log:403, LoggerConfig (org.apache.logging.log4j.core.config) log:63, AwaitCompletionReliabilityStrategy (org.apache.logging.log4j.core.config) logMessage:146, Logger (org.apache.logging.log4j.core) tryLogMessage:2163, AbstractLogger (org.apache.logging.log4j.spi) logMessageTrackRecursion:2118, AbstractLogger (org.apache.logging.log4j.spi) logMessageSafely:2101, AbstractLogger (org.apache.logging.log4j.spi) logMessage:2012, AbstractLogger (org.apache.logging.log4j.spi) logIfEnabled:1883, AbstractLogger (org.apache.logging.log4j.spi) info:184, Log4jLogger (org.apache.logging.slf4j) main:10, Log4j2Test