How to configure Log4j in Tomcat

来源:互联网 发布:ubuntu安装gfirefly 编辑:程序博客网 时间:2024/04/30 19:45

Steps below explain how to configure Tomcat to use log4j system.

1. Download extra components including extras/tomcat-juli.jar, extras/tomcat-juli-adapters.jar in Apchee tomcat home page.

2. Replace $CATALINA_HOME/bin/tomcat-juli.jar with extras/tomcat-juli.jar just downloaded.

3. Place estras/tomcat-juli-adapters.jar in $CATALINA_HOME/lib.

4. Delete $CATALINA_HOME/conf/logging.properties file.

5. Writing log4j.properties file and put on $CATALINA_HOME/lib. This properties file is responsible for Tomcat’s internal logging. Please refer to the attachment.

6. Download Log4J (v1.2 or later) and place the log4j jar in $CATALINA_HOME/lib.

7. Web applications should certainly use their own log4j configuration. Please place your log4j.properties file in your web application’s WEB-INF/classes, and log.xx.jar into WEB-INF/lib.

Henceforth, you do not write any source code regarding the log4j, but the log4j.properties. Tomcat will load all the things with the Applications starting up.

原创粉丝点击