I'm having issues with the log4j2 rolling file appender. It only writes the first rollover file.
Here's my config:
status = error
name = LogstashPropertiesConfig
appender.console.type = Console
appender.console.name = plain_console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c]%notEmpty{[%X{pipeline.id}]}%notEmpty{[%X{plugin.id}]} %m%n
appender.rolling.type = RollingFile
appender.rolling.name = plain_rolling
appender.rolling.fileName = ${sys:ls.logs}/logstash-current.log
appender.rolling.filePattern = ${sys:ls.logs}/{yyyy-MM-dd}-%i.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c]%notEmpty{[%X{pipeline.id}]}%notEmpty{[%X{plugin.id}]} %m%n
appender.rolling.avoid_pipelined_filter.type = PipelineRoutingFilter
appender.rolling.policies.type = Policies
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size = 10MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.fileIndex = nomax
rootLogger.level = ${sys:ls.log.level}
rootLogger.appenderRef.console.ref = ${sys:ls.log.format}_console
rootLogger.appenderRef.rolling.ref = ${sys:ls.log.format}_rolling
I would expect this config to roll over every 10MB, creating the files:
- 2023-10-18-1.log
- 2023-10-18-2.log
- 2023-10-18-3.log
- ...etc
- logstash-current.log
where logstash-current.log
is the log currently being written to, and the others being older data at 10MB each.
Instead, what I'm seeing is this:
- 2023-10-18-1.log
- logstash-current.log
The 2023-10-18-1.log
file is indeed 10MB, but instead of creating 2023-10-18-2.log
, log4j2 just deletes and reuses logstash-current.log
(which never grows over 10MB).
Any thoughts?