deppfx
deppfx

Reputation: 751

Tomcat logs compression and rotation

I am pretty new with Tomcat.

What I am looking for is:
For Tomcat to rotate files based on size, compress & delete the old files after compression.

My current log files are configured in various locations as mentioned below. I am not sure if this is the right way to handle these logs in Tomcat.

localhost_access_log   /var/lib/tomcatmulti/frontend/conf/server.xml  
netbiscuits-perf.log   /var/lib/tomcatmulti/frontend/webapps/ROOT/WEB-INF/classes/log4j.xml 
catalina.out           /usr/share/tomcat7/bin/catalina.sh

Please don't suggest logrotate. If you are to, I would like to understand why Tomcat WONT rotate it as I feel that this is something the application should be capable of doing.

Upvotes: 1

Views: 5452

Answers (1)

Stefan
Stefan

Reputation: 12453

How can I find which logging engine is my Tomcat using ?

I would have a look at the manual. Choose one from "documentation" at the left. In its default state Tomcat is using "JULI" a mix of Java Util Logging (JUL) and Apache Commons Logging.

Does this mean that my tomcat has log4j enabled ?

No, your application doesn't. Sure you can also make Tomcat use Log4j, refer also to the docs.

How can I rotate the logs for the above files ? ... Please don't suggest logrotate.

Ok, I won't. Use a RollingFileAppender. My Tomcat is rotating logs by default. Did you check the rules for rotation?

To keep it short: "localhost_access_log" and "catalina.out" are created by the Juli framework from Tomcat and "netbiscuits-perf.log" is created by Log4J. These are different frameworks and dont work together without you explicitly doing some work.

I would recommend you add SLF4j to your app. It's a facade that collects the loggings from other frameworks (except Log4j2) and redirects them to the framework of your choice. That way you can use a modern framework like Logback to do the final work, like creating files using the RollingFileAppender.

Upvotes: 1

Related Questions