很多时候,我们图方便,直接在Eclipse启动项目,有时候排查问题,在console看日志不方便,那怎样在log4j查看日志呢,只要在log4j配置 把log4j指定到具体位置 即可
- ### set log levels ###
- log4j.rootLogger = debug , Console , D
- #Console
- log4j.appender.Console=org.apache.log4j.ConsoleAppender
- log4j.appender.Console.layout=org.apache.log4j.PatternLayout
- log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
- #output2file
- log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
- log4j.appender.D.File = E:\\teenagers-report.log
- log4j.appender.D.Append = true
- log4j.appender.D.Threshold = INFO \#\# \u8F93\u51FAinfo\u7EA7\u522B\u4EE5\u4E0A\u7684\u65E5\u5FD7
- log4j.appender.D.layout = org.apache.log4j.PatternLayout
- log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
- log4j.logger.com.ibatis=DEBUG
- log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
- log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
- log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
- log4j.logger.java.sql.Connection=DEBUG
- log4j.logger.java.sql.Statement=DEBUG
- log4j.logger.java.sql.PreparedStatement=D
- [plain] view plain copy
- 把日志文件输出到 E 盘的 文件中 查看:
- log4j.appender.D.File = E:\\teenagers-report.log