You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Srijeet Chatterjee (Jira)" <ji...@apache.org> on 2022/11/08 19:27:00 UTC
[jira] [Created] (LOG4J2-3630) Unable to prevent file renames during rollovers
Srijeet Chatterjee created LOG4J2-3630:
------------------------------------------
Summary: Unable to prevent file renames during rollovers
Key: LOG4J2-3630
URL: https://issues.apache.org/jira/browse/LOG4J2-3630
Project: Log4j 2
Issue Type: Bug
Components: Configuration
Reporter: Srijeet Chatterjee
We have an app that's using log4j2 for logging. The file that we want to be logging to is
{code:java}
access.log
{code}
The current log4j2 config causes it to rename {{access.log}} to {{access.log.2022-01-30-30}} (for example) then recreate the {{access.log}} file. This can cause data loss problems for log forwarding tools that expect to tail the same log file without having it change out from underneath them.
I have tried playing around with the `DirectWriteRolloverStrategy` attribute, but by using that, I lose the ability to start with a specified `fileName`, because this policy doesn't support the `fileName` parameter. Hence, we'd lose the ability to log to `access.log`.
Is there a way around this?
Desired behavior:
Current logging always goes to `access.log`.
The files rollover based on the strategy specified in my log4j2 config file.
Renames do not happen for the current file.
Here's my current config file:
{code:java}
<?xml version='1.0' encoding='utf-8'?>
<Configuration>
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="%m%n" />
</Console>
<RollingFile name="traffic_router_access"
fileName="access.log"
filePattern="access.log.%i" >
<PatternLayout pattern="%m%n" />
<Policies>
<SizeBasedTriggeringPolicy size="10KB"/>
</Policies>
<DirectWriteRolloverStrategy maxFiles="10"/>
<ThresholdFilter level="INFO" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="org.apache.traffic_control.traffic_router.core.access" level="INFO" additivity="false" >
<AppenderRef ref="traffic_router_access" />
</Logger>
<Root level="WARN" additivity="false" >
<AppenderRef ref="stdout" />
</Root>
</Loggers>
</Configuration> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)