Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
We have an app that's using log4j2 for logging. The file that we want to be logging to is
access.log
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:
<?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>