How To Setup Logback with Tomcat 6 on Windows

2019-03-02 06:12发布

问题:

I have tomcat6 installed on my Windows desktop for testing purpose. At the moment nothing is added to the webapps folder, just the normal tomcat start up. Following log files are produced:

catalina.2011-12-24.log
host-manager.2011-12-24.log
jakarta_service_20111224.log
localhost.2011-12-24.log
manager.2011-12-24.log
stderr_20111224.log
stdout_20111224.log

My problem is simple, I want these logs [stdout included] to be rolled and compressed on the basis of defined size limit.

I have read about logback and its capabilities to roll and compress files with defined policies, but I have not been able to make it work for me. I have copied following jars in $TOMCAT_HOME/lib directory:

logback-access-1.0.0.jar
logback-classic-1.0.0.jar
logback-core-1.0.0.jar

Some sites suggested these libs should be added as well:

jul-to-slf4j-1.6.4.jar
slf4j-api-1.6.4.jar

I have tried copying logback.xml in $TOMCAT_HOME/conf and $TOMCAT_HOME/lib, but unable to make it work.

I would really appreciate if someone can help me with this, best could provide me with a logback.xml and jars/xml location where these files should be copied to make it work.

P.S. I have not deployed any webapp in the tomcat, it just the basic tomcat setup.

回答1:

I think this tutorial can help. Tomcat 6 works only with log....0.9.30.jar or lower. Tomcat + SLF4J + Logback