Reputation: 738
I am generating tomcat localhost access logs using the class -
<Valve className="org.apache.catalina.valves.AccessLogValve" fileDateFormat="yyyy-MM-dd.HH:mm" renameOnRotate="true" prefix="localhost_access_log" suffix=".txt" maxDays="<%= @access_log_max_days %>"
Since my node doesn't have sufficient memory for all access logs, I would like to delete the rotated files after 10 min or so. My question is how can we provide a decimal value (or < 1days) value for maxDays
construct so that deletion of rotated files occurs more rapidly than once everyday?
Any help will be much appreciated. Thanks in advance!
Upvotes: 0
Views: 1378
Reputation: 16055
You can't, the value of maxDays
is an integer, with values not greater than 0
meaning no rotation. So the minimal value you can set is 1
.
Anyway log files spanning a couple of minutes wouldn't allow you to diagnose almost any problem. Logs take a couple of orders of magnitude less space on disk, than any web application you might deploy, so I don't think rotating logs every day will be a problem.
Edit: A setting of maxDays="1"
will still leave you with two log files: the current one and the previous one. If you wish to have just the current one you can disable rotation in Tomcat and use an external utility like logrotate:
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="localhost_access_log"
suffix=".txt"
rotatable="false"
checkExists="true" />
Logrotate can rotate based on file size, so it should resolve your problem.
Upvotes: 1