[
https://issues.apache.org/jira/browse/LOG4J2-2330?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jason Ricles updated LOG4J2-2330:
---------------------------------
Description:
I have a log rotation setup for my application to rotate logs and compress the
logs into a gzip file based on both time and size (tried on multiple log42j
version). The rotation and compression for time-based work great and creates a
gzip file with a unique file name.
However, when I do size based log rotation, the gzip file name is not unique
and keeps using the same name even though the gzip has the time in the filename
and thus the time is not updating. Which leads to the new gzip file overwriting
the previous gzip file from stepping through the code it appears to be a bug
unless my configuration file is incorrect.
was:
I have a log rotation setup for my application to rotate logs and compress the
logs into a gzip file based on both time and size. The rotation and compression
for time-based work great and creates a gzip file with a unique file name.
However, when I do size based log rotation, the gzip file name is not unique
and keeps using the same name even though the gzip has the time in the filename
and thus the time is not updating. Which leads to the new gzip file overwriting
the previous gzip file from stepping through the code it appears to be a bug
unless my configuration file is incorrect.
> Log4j2 size rotation keeps renaming gzip file same name
> -------------------------------------------------------
>
> Key: LOG4J2-2330
> URL: https://issues.apache.org/jira/browse/LOG4J2-2330
> Project: Log4j 2
> Issue Type: Bug
> Environment: RHEL 6.9 32bit with DISA STIG
> ([https://www.stigviewer.com/stig/red_hat_enterprise_linux_6/)] settings
> applied along with the following log4j2.xml file
>
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="ALL" shutdownHook="disable">
> <Properties>
> <Property name="logdir">${env:DIR}/log</Property>
> <Property name="eventfilename">foo_event</Property>
> <Property name="errorfilename">foo_error</Property>
> <Property name="msgformat">%d{yyyy-MM-dd HH:mm:ss.SSS}{GMT+0}Z [%t]
> %-5level %logger{1} - %msg%n</Property>
> </Properties>
> <Appenders>
> <Console name="Console" target="SYSTEM_OUT">
> <PatternLayout pattern="${msgformat}"/>
> </Console>
> <RollingFile name="ERROR_FILE"
> fileName="${logdir}/${errorfilename}.log"
>
> filePattern="${logdir}/${errorfilename}-%d{yyyyMMddHHmmss}{GMT+0}.log.gz">
> <PatternLayout charset="UTF-8" pattern="${msgformat}"/>
> <Policies>
> <SizeBasedTriggeringPolicy size="10 MB"/>
> </Policies>
> <DefaultRolloverStrategy>
> <Delete basePath="${logdir}">
> <IfFileName glob="${errorfilename}-*">
> <IfAccumulatedFileSize exceeds="100 MB"/>
> </IfFileName>
> </Delete>
> </DefaultRolloverStrategy>
> <ThresholdFilter level="WARN"/>
> </RollingFile>
> <RollingFile name="EVENT_FILE"
> fileName="${logdir}/${eventfilename}.log"
>
> filePattern="${logdir}/${eventfilename}-%d{yyyyMMddHHmmss}{GMT+0}.log.gz">
> <PatternLayout charset="UTF-8" pattern="${msgformat}"/>
> <Policies>
> <TimeBasedTriggeringPolicy interval="43200" modulate="false"/>
> <SizeBasedTriggeringPolicy size="1 MB"/>
> </Policies>
> <DefaultRolloverStrategy>
> <Delete basePath="${logdir}">
> <IfFileName glob="${eventfilename}-*">
> <IfAccumulatedFileSize exceeds="100 MB"/>
> </IfFileName>
> </Delete>
> </DefaultRolloverStrategy>
> <ThresholdFilter level="TRACE"/>
> </RollingFile>
> </Appenders>
> <Loggers>
> <Logger name="foo.utils.FooLogger" level="TRACE"
> additivity="false">
> <AppenderRef ref="ERROR_FILE"/>
> <AppenderRef ref="EVENT_FILE"/>
> </Logger>
> <Logger name="foo.utils.foo.FooPathUtils" level="INFO"
> additivity="false">
> <!-- Change level to debug to log java path info at startup -->
> <AppenderRef ref="ERROR_FILE"/>
> <AppenderRef ref="EVENT_FILE"/>
> </Logger>
> <Logger name="foo" level="INFO" additivity="false">
> <AppenderRef ref="ERROR_FILE"/>
> <AppenderRef ref="EVENT_FILE"/>
> </Logger>
> <Root level="TRACE">
> <AppenderRef ref="Console" />
> </Root>
> </Loggers>
> </Configuration>
> {code}
> Reporter: Jason Ricles
> Priority: Major
>
> I have a log rotation setup for my application to rotate logs and compress
> the logs into a gzip file based on both time and size (tried on multiple
> log42j version). The rotation and compression for time-based work great and
> creates a gzip file with a unique file name.
>
> However, when I do size based log rotation, the gzip file name is not unique
> and keeps using the same name even though the gzip has the time in the
> filename and thus the time is not updating. Which leads to the new gzip file
> overwriting the previous gzip file from stepping through the code it appears
> to be a bug unless my configuration file is incorrect.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)