log4j入门
日志是应用软件中不可缺少的部分,Apache的开源项目log4j是一个功能强大的日志组件,提供方便的日志记录。在apache网站:jakarta.apache.org/log4j 可以免费下载到Log4j最新版本的软件包。
详见他人博客:
http://www.codeceo.com/article/log4j-usage.html,
http://www.cnblogs.com/alipayhutu/archive/2012/06/21/2558249.html
自定义appender:
http://www.cnblogs.com/LinkinPark/p/5232837.html,
http://blog.csdn.net/wlbing0625/article/details/7888092
项目中一个log4j配置文件,存起来以后看
# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml! # For all other servers: Comment out the Log4J listener in web.xml to activate Log4J. log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %p [%c] - %m%n log4j.appender.masfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.masfile.DatePattern='_'yyyy-MM-dd log4j.appender.masfile.File=${travel.root}/WEB-INF/logs/mas/mas.log # Pattern to output: date priority [category] - message log4j.appender.masfile.layout=org.apache.log4j.PatternLayout log4j.appender.masfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %p [%c] - %m%n log4j.appender.solidfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.solidfile.DatePattern='_'yyyy-MM-dd log4j.appender.solidfile.File=${travel.root}/WEB-INF/logs/solid/solid.log # Pattern to output: date priority [category] - message log4j.appender.solidfile.layout=org.apache.log4j.PatternLayout log4j.appender.solidfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %p [%c] - %m%n log4j.appender.sqlfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.sqlfile.DatePattern='_'yyyy-MM-dd log4j.appender.sqlfile.File=${travel.root}/WEB-INF/logs/sql/sql.log # Pattern to output: date priority [category] - message log4j.appender.sqlfile.layout=org.apache.log4j.PatternLayout log4j.appender.sqlfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %p [%c] - %m%n log4j.appender.logfile=org.apache.log4j.RollingFileAppender log4j.appender.logfile.File=${travel.root}/WEB-INF/logs/message.log log4j.appender.logfile.MaxFileSize=4096KB # Keep three backup files. log4j.appender.logfile.MaxBackupIndex=5 # Pattern to output: date priority [category] - message log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %p [%c] - %m%n log4j.appender.debugfile=org.apache.log4j.RollingFileAppender log4j.appender.debugfile.File=${travel.root}/WEB-INF/logs/debug/debug.log log4j.appender.debugfile.MaxFileSize=4096KB # Keep three backup files. log4j.appender.debugfile.MaxBackupIndex=5 # Pattern to output: date priority [category] - message log4j.appender.debugfile.layout=org.apache.log4j.PatternLayout log4j.appender.debugfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %p [%c] - %m%n #info, debug, logfile log4j.rootCategory=info, stdout, logfile #log4j.logger.org.springframework.data.redis=debug, stdout, logfile #log4j.logger.com.scenic.queue.runnable.DataMigrationRunnable=info, stdout, logfile log4j.logger.java.sql.Connection=debug, sqlfile #log4j.logger.com.scenic.queue.runnable = DEBUG, stdout #log4j.logger.com.scenic.datasource.DynamicRoutingDataSource = DEBUG, debugfile #log4j.logger.com.scenic.mas = INFO, masfile #log4j.logger.com.scenic.collect = INFO, solidfile
Become a Linux Programmer