I am writing Tomcat log with this setting:
Log configured using an
AccessLogValve
inserver.xml
Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/access" prefix="access" suffix=".log" pattern="common" rotatable="false"
Use
logrotate
to rotate the log file daily and remove old log files./app/logs/access/access.log { daily dateext missingok rotate 14 maxage 14 compress delaycompress dateyesterday }
The strange thing is that every day the log file is changed to a new name by logrotate
, for example access.log-20171222
, and a new log file access.log
is created. However, Tomcat still writes log to the renamed file.
My solution now is adding the option copytruncate
to the configuration file of logrotate
. However, with this option, there is a chance of losing some log at the time of truncating.
Can anyone suggest a better solution?
Thank you.