Description
Log files do not seem to be rolling up to the max number of files as specified in DefaultRolloverStrategy while utilizing a SizeBasedTriggeringPolicy. It is just rolling just to 1 file.
Simple repro:
log4j2.xml
<?xml version="1.0" encoding="UTF-8"?> <Configuration status="INFO" name="MyApp"> <Appenders> <RollingFile name="rolling" fileName="__logs__/rolling.log" filePattern="__logs__/rolling.log.%i" immediateFlush="true"> <PatternLayout pattern="%d %5p [%t] (%c) - %m%n"/> <SizeBasedTriggeringPolicy size="1MB"/> <DefaultRolloverStrategy max="10"/> </RollingFile> </Appenders> <Loggers> <Root level="INFO"> <AppenderRef ref="rolling"/> </Root> </Loggers> </Configuration>
MyApp.scala:
import scala.util.Random import org.apache.logging.log4j.LogManager object MyApp extends App { val log = LogManager.getLogger(this.getClass) var counter = 0L var bytes = new Array[Byte](1000) while (true) { Random.nextBytes(bytes) log.info(f"Log statement: $counter%08x ${bytes.mkString}") counter += 1 Thread.sleep(5) } }
If you run that against 2.7, things roll fine. If you run that against 2.8, you'll only see rolling.log & rolling.log.1 in the _logs_ folder.
Attachments
Attachments
Issue Links
- Blocked
-
STORM-2617 log4j2 RollingFile rotation failing
- Open
- is broken by
-
LOG4J2-1101 Date based file appender
- Resolved
- is duplicated by
-
LOG4J2-1821 (not only) default rollover strategy is *broken*
- Resolved