包含所有日志
private static Logger logger = Logger.getLogger(xxx.class.getName());
log4j.rootLogger=info,All
log4j.appender.All=org.apache.log4j.ConsoleAppender
log4j.appender.All.Target=System.out
log4j.appender.All.layout=org.apache.log4j.PatternLayout
log4j.appender.All.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
只有mongodb分类使用
private static final Logger logger = Logger.getLogger("mongodb");
log4j.logger.mongodb=info,appenderMongodutils
log4j.appender.appenderMongodutils=org.apache.log4j.RollingFileAppender
log4j.appender.appenderMongodutils.File=/data/mongodb.log
log4j.appender.appenderMongodutils.MaxFileSize=20MB
log4j.appender.appenderMongodutils.MaxBackupIndex=100
log4j.appender.appenderMongodutils.layout=org.apache.log4j.PatternLayout
log4j.appender.appenderMongodutils.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss,SSS}] - %m%n
log4j.appender.appenderMongodutils.encoding=UTF-8