1.tomcat下面 Log4j.properties不認(rèn), 只認(rèn)log4j.properties
resource url:
http://www.aygfsteel.com/zJun/archive/2006/06/30/55511.html#55860
2.關(guān)于“l(fā)og4j:WARN Please initialize the log4j system properly”:
? 你的tomcat/common/lib下是不是有個(gè)log4j的jar啊?刪了試試!應(yīng)該沒問題。
resource url:http://www.yeyan.info/100-tomcat-t622836.htm
3.在tomcat中配置log4j似乎只要三步就可以實(shí)現(xiàn)了:
第一步:把log4j.jar放入$CATALINA_HOME/common/lib.
第二步:將log4j配置文件,可以是log4j.xml,log4j.properties;放進(jìn)你的項(xiàng)目/WEB-INF/classes/目錄下.
第三步:重啟tomcat.
這樣直接在.java程序中使用Logger,就可以按照配置文件輸出日志了。
嗚嗚,157已經(jīng)搬走了,只能回到學(xué)校試驗(yàn)一下。
可能自己以前就是因?yàn)闆]有把配置文件命名為log4j.properties,而是命名為了log4jconfig.properties,所以tomcat總是找不到這個(gè)配置文件。
4.在tomcat中配置log4j步驟補(bǔ)充:
? 剛又查了幾個(gè)權(quán)威資料,好像tomcat中配置log44j還必須下載commons-logging.jar (not commons-logging-api.jar) 和log4j.jar一起放到 $CATALINA_HOME/common/lib .
相關(guān)資料:
1.使用log4j為Tomcat輸出日志
http://www.chinawin.net/myblog/archives/314-log4jTomcataeoeOE.html
1. 如果Tomcat當(dāng)前正在運(yùn)行,關(guān)閉Tomcat。
2. 從Apache的網(wǎng)站下載Commons Logging發(fā)行包。
3. 將壓縮包中的commons-logging.jar解壓縮到你Tomcat安裝路徑的common/lib目錄中。
4. 從Apache的網(wǎng)站下載Log4j發(fā)行包。
5. 將壓縮包中的log4j-1.2.12.jar解壓縮到你Tomcat安裝路徑的common/lib目錄中。
6. 在Tomcat安裝路徑的common/classes 創(chuàng)建log4j的配置文件log4j.properties(配置文件在隨后一節(jié))。
7. 重起Tomcat
2.Tomcat FAQ
Logging http://tomcat.apache.org/faq/logging.html#userWebapps
How should I log in my own webapps?
While you can use System.out and System.err to log, we strongly recommend using a toolkit like Log4J or JDK 1.4's java.util.logging package. With these toolkits, you have significantly more functionality (for example, sending emails, logging to a database, controlling at runtime the logging level of different classes, inspecting the logs with a graphical viewer, etc.) than with Tomcat's built-in default logging configuration.
We also recommend that you separate your logging from Tomcat's internal logging. That means you should bundle your logging toolkit with your webapp. If you're using Log4J, for example, place the Log4J jar in the WEB-INF/lib directory of your webapp and the Log4J configuration file in the WEB-INF/classes directory of your webapp. This way different web applications can have different logging configurations and you don't need to worry about them interfering with each other.
3.Logging in Tomcat
http://tomcat.apache.org/tomcat-5.5-doc/logging.html
參考資料:
1.Tomcat5.5 with log4j?
http://itvincent.blog.hexun.com/5561505_d.html
2.log4j-1.2.9.在tomcat5.5下面的配置
http://www.cnblogs.com/zhoup/archive/2006/01/18/319817.aspx
resource url:
http://www.aygfsteel.com/zJun/archive/2006/06/30/55511.html#55860
2.關(guān)于“l(fā)og4j:WARN Please initialize the log4j system properly”:
? 你的tomcat/common/lib下是不是有個(gè)log4j的jar啊?刪了試試!應(yīng)該沒問題。
resource url:http://www.yeyan.info/100-tomcat-t622836.htm
3.在tomcat中配置log4j似乎只要三步就可以實(shí)現(xiàn)了:
第一步:把log4j.jar放入$CATALINA_HOME/common/lib.
第二步:將log4j配置文件,可以是log4j.xml,log4j.properties;放進(jìn)你的項(xiàng)目/WEB-INF/classes/目錄下.
第三步:重啟tomcat.
這樣直接在.java程序中使用Logger,就可以按照配置文件輸出日志了。
嗚嗚,157已經(jīng)搬走了,只能回到學(xué)校試驗(yàn)一下。
可能自己以前就是因?yàn)闆]有把配置文件命名為log4j.properties,而是命名為了log4jconfig.properties,所以tomcat總是找不到這個(gè)配置文件。
4.在tomcat中配置log4j步驟補(bǔ)充:
? 剛又查了幾個(gè)權(quán)威資料,好像tomcat中配置log44j還必須下載commons-logging.jar (not commons-logging-api.jar) 和log4j.jar一起放到 $CATALINA_HOME/common/lib .
相關(guān)資料:
1.使用log4j為Tomcat輸出日志
http://www.chinawin.net/myblog/archives/314-log4jTomcataeoeOE.html
1. 如果Tomcat當(dāng)前正在運(yùn)行,關(guān)閉Tomcat。
2. 從Apache的網(wǎng)站下載Commons Logging發(fā)行包。
3. 將壓縮包中的commons-logging.jar解壓縮到你Tomcat安裝路徑的common/lib目錄中。
4. 從Apache的網(wǎng)站下載Log4j發(fā)行包。
5. 將壓縮包中的log4j-1.2.12.jar解壓縮到你Tomcat安裝路徑的common/lib目錄中。
6. 在Tomcat安裝路徑的common/classes 創(chuàng)建log4j的配置文件log4j.properties(配置文件在隨后一節(jié))。
7. 重起Tomcat
2.Tomcat FAQ
Logging http://tomcat.apache.org/faq/logging.html#userWebapps
How should I log in my own webapps?
While you can use System.out and System.err to log, we strongly recommend using a toolkit like Log4J or JDK 1.4's java.util.logging package. With these toolkits, you have significantly more functionality (for example, sending emails, logging to a database, controlling at runtime the logging level of different classes, inspecting the logs with a graphical viewer, etc.) than with Tomcat's built-in default logging configuration.
We also recommend that you separate your logging from Tomcat's internal logging. That means you should bundle your logging toolkit with your webapp. If you're using Log4J, for example, place the Log4J jar in the WEB-INF/lib directory of your webapp and the Log4J configuration file in the WEB-INF/classes directory of your webapp. This way different web applications can have different logging configurations and you don't need to worry about them interfering with each other.
3.Logging in Tomcat
http://tomcat.apache.org/tomcat-5.5-doc/logging.html
Follow the following steps to setup a file named tomcat.log that has internal Tomcat logging output to it:
- Create a file called log4j.properties with the following content and save it
into common/classes.
log4j.rootLogger=debug, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.logger.org.apache.catalina=DEBUG, R - Download Log4J (v1.2 or later) and place the log4j jar in $CATALINA_HOME/common/lib.
- Download Commons Logging and place the commons-logging.jar (not commons-logging-api.jar) in $CATALINA_HOME/common/lib with the log4j jar.
- Start Tomcat
參考資料:
1.Tomcat5.5 with log4j?
http://itvincent.blog.hexun.com/5561505_d.html
2.log4j-1.2.9.在tomcat5.5下面的配置
http://www.cnblogs.com/zhoup/archive/2006/01/18/319817.aspx