villajo commented on issue #6533:
URL:
https://github.com/apache/trafficcontrol/issues/6533#issuecomment-1311983448
So, after reviewing the issue, the code and then reviewing the default
configuration used on Traffic Router. I feel that a different approach would be
better.
The problem with the directwriterolloverstrategy and the delete function is
that the access.log is renamed/moved instead of copied. This changes the inode
on access.log and other log forwarding applications will retain the lock to the
file with the original inode.. Which is renamed. This is why we're seeing this
problem.
After reviewing the log4j2 rotation strategies there is nothing available in
log4j2 that does what we need, which would be a copy to new file retaining the
inode, then truncate access.log. Now, I could create a plugin, but that leads
me back to a philosophy idea that the goal of Traffic Router in this situation
should be just getting the logs to a location and from there, it should be the
job of the operating system or admin of said system to figure out how the logs
are sliced up and rotated using an outside application. In this case, I feel
logrotate does this reliably.
I simplified the configuration of our log4j2.xml to only use one file for
both the traffic_router.log and access.log. Then I used logrotate with the
below configuration to copytruncate daily.
`/opt/traffic_router/var/log/access.log {
daily
size 1k
compress
rotate 7
dateformat -%d%m%Y
copytruncate
}
/opt/traffic_router/var/log/traffic_router.log {
daily
size 1k
compress
rotate 7
dateformat -%d%m%Y
copytruncate
}`
This is the new log4j2.xml that I'm purposing to solve this issue on
production systems.
`<!-- file deployed via ansible push, local edits are subject to be
overwritten -->
<Configuration packages="org.apache.trafficrouter.trafficrouterappender"
verbose="true">
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="%m%n" />
</Console>
<File name="traffic_router"
fileName="/opt/traffic_router/var/log/traffic_router.log" immediateFlush="true"
append="true">
<PatternLayout pattern="%-5p %d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%t]
%c - %m%n" />
<ThresholdFilter level="ALL" />
</File>
<File name="traffic_router_access"
fileName="/opt/traffic_router/var/log/access.log" immediateFlush="true"
append="true">
<PatternLayout pattern="%m%n" />
<ThresholdFilter level="INFO" />
</File>
</Appenders>
<Loggers>
<Root level="WARN" additivity="false" >
<AppenderRef ref="stdout" />
</Root>
<Logger name="org.apache.traffic_control.traffic_router"
level="INFO" additivity="false" >
<AppenderRef ref="traffic_router" />
</Logger>
<Logger name="org.apache.traffic_control.traffic_router.core.access"
level="INFO" additivity="false" >
<AppenderRef ref="traffic_router_access" />
</Logger>
</Loggers>
</Configuration>`
I'm still waiting for word from Zach whether this is acceptable or not, but
I feel this is probably cleanest way to fix this issue. Thoughts?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]