1.tomcat下面 Log4j.properties不認, 只認log4j.properties
resource url:
http://www.aygfsteel.com/zJun/archive/2006/06/30/55511.html#55860

2.關于“log4j:WARN Please initialize the log4j system properly”:
? 你的tomcat/common/lib下是不是有個log4j的jar啊?刪了試試!應該沒問題。

resource url:http://www.yeyan.info/100-tomcat-t622836.htm

3.在tomcat中配置log4j似乎只要三步就可以實現了:
第一步:把log4j.jar放入$CATALINA_HOME/common/lib.
第二步:將log4j配置文件,可以是log4j.xml,log4j.properties;放進你的項目/WEB-INF/classes/目錄下.
第三步:重啟tomcat.

這樣直接在.java程序中使用Logger,就可以按照配置文件輸出日志了。

嗚嗚,157已經搬走了,只能回到學校試驗一下。

可能自己以前就是因為沒有把配置文件命名為log4j.properties,而是命名為了log4jconfig.properties,所以tomcat總是找不到這個配置文件。

4.在tomcat中配置log4j步驟補充:
? 剛又查了幾個權威資料,好像tomcat中配置log44j還必須下載commons-logging.jar (not commons-logging-api.jar) 和log4j.jar一起放到 $CATALINA_HOME/common/lib .
相關資料:
1.使用log4j為Tomcat輸出日志
http://www.chinawin.net/myblog/archives/314-log4jTomcataeoeOE.html

1. 如果Tomcat當前正在運行,關閉Tomcat。
2. 從Apache的網站下載Commons Logging發行包。
3. 將壓縮包中的commons-logging.jar解壓縮到你Tomcat安裝路徑的common/lib目錄中。
4. 從Apache的網站下載Log4j發行包。
5. 將壓縮包中的log4j-1.2.12.jar解壓縮到你Tomcat安裝路徑的common/lib目錄中。
6. 在Tomcat安裝路徑的common/classes 創建log4j的配置文件log4j.properties(配置文件在隨后一節)。
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:

  1. 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
  2. Download Log4J (v1.2 or later) and place the log4j jar in $CATALINA_HOME/common/lib.
  3. Download Commons Logging and place the commons-logging.jar (not commons-logging-api.jar) in $CATALINA_HOME/common/lib with the log4j jar.
  4. 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