Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the date pattern from tomcat logs

Tags:

By default Tomcat appends the date to log files e.g., localhost.2010-12-22.log and same with the catalina log. I don't want the date in the log file and I can't seem to find how to remove it. The logging documentation doesn't say anything about the date pattern. Any ideas are greatly appreciated.

http://tomcat.apache.org/tomcat-6.0-doc/logging.html

like image 840
Andrew Avatar asked Dec 22 '10 17:12

Andrew


People also ask

Can I delete Tomcat logs?

You can delete all logs. Those from the current date will not be deletable while Tomcat is running, but that is ok.


2 Answers

None of the other answers helped me much, though Thomas's was closest. The documentation I found was:

  • http://tomcat.apache.org/tomcat-6.0-doc/logging.html
  • http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/juli/FileHandler.html

So I added the following to Tomcat's logging.properties file. This removes the date from the localhost logs, and the other three log types that Tomcat dates by default:

    1catalina.org.apache.juli.FileHandler.rotatable = false    2localhost.org.apache.juli.FileHandler.rotatable = false      3manager.org.apache.juli.FileHandler.rotatable = false 4host-manager.org.apache.juli.FileHandler.rotatable = false    #    # default is true, which causes a date to be added to the filename      1catalina.org.apache.juli.FileHandler.suffix = log    2localhost.org.apache.juli.FileHandler.suffix = log      3manager.org.apache.juli.FileHandler.suffix = log 4host-manager.org.apache.juli.FileHandler.suffix = log    #    # default is .log, but without date, the extra dot is not needed 
like image 52
Michael Allan Avatar answered Sep 27 '22 16:09

Michael Allan


de_simakov's answer was correct for the most part - but it had a one letter typo. Find a configuration similar to this in conf/server.xml

<Valve className="org.apache.catalina.valves.AccessLogValve"       directory="logs"  prefix="http_access" suffix="log"  pattern="common"        rotatable="false" resolveHosts="false" /> 

Notice the rotatable="false" attribute.

like image 23
SalmanMalik Avatar answered Sep 27 '22 17:09

SalmanMalik