Change retention period of tomcat8 localhost_access_log files

My tomcat 8 logs folder (/tomcat/logs) is using up lots of disk space with localhost_access_log files.

According to this post:
Tomcat localhost_access_log files cleanup

I can edit the /tomcat/conf/server.xml file’s preexisting “Valve” element to introduce a “maxDays” param, so it would look like this:

<Server port="1234" shutdown="SHUTDOWN">
  <Service name="Catalina">
    <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost"  appBase="foo" unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log" suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" **maxDays="10"** />
      </Host>
    </Engine>
  </Service>
</Server>

Is editing this server.xml file directly safe, or is there a preferred way to change this in tomcat8? I suppose a server restart is required.

Thanks

Leave a Comment