1. Download Log4j.jar on the official website
2. Copy the Log4j.jar to the Web-info/lib folder.
3. Create the Log4j.properties file and store it in the SRC root directory.
Fill in the following file information:
log4j.rootlogger=info, serverdailyrollingfile, stdout log4j.appender.ServerDailyRollingFile= Org.apache.log4j.DailyRollingFileAppender #每天一个日志文件log4j. Appender.ServerDailyRollingFile.DatePattern= '. ' yyyy-mm-dd log4j.appender.ServerDailyRollingFile.File=e:/moneyassist/running.log Log4j.appender.ServerDailyRollingFile.layout=org.apache.log4j.PatternLayout Log4j.appender.ServerDailyRollingFile.layout.ConversionPattern=%d{yyyy-mm-dd HH:mm:ss}%p [%c:%l]%m%n%n# Debug information output format Log4j.appender.ServerDailyRollingFile.Append=true
#追加
4. Call in Java code:
Logger Logger = Logger.getlogger (this. GetClass), Logger.info ("Hello World");
Using log4j to implement log management in Javaweb