日期:2014-05-20 浏览次数:21123 次
log4j.rootLogger=INFO,A1 //日志生成级别 log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender //控制台 log4j.appender.A1.file=log_console_out //文件名 log4j.appender.A1.DatePattern='.'yyyy-MM-dd //日志文件改名(重名就改)(比如今天21号,日志为log_console_out,那么明天就变成log_console_out.2009-01-21 ) log4j.appender.A1.layout=org.apache.log4j.PatternLayout //日志格式 log4j.appender.A1.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] -=> %m%n //也是定义格式的转换 log4j.logger.normalout=debug,A2 log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender log4j.appender.A2.file=log_normal_out log4j.appender.A2.DatePattern='.'yyyy-MM-dd log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] -=> %m%n log4j.logger.debugout=debug,A4 log4j.appender.A4=org.apache.log4j.DailyRollingFileAppender log4j.appender.A4.file=log_debug_out log4j.appender.A4.DatePattern='.'yyyy-MM-dd log4j.appender.A4.layout=org.apache.log4j.PatternLayout log4j.appender.A4.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] -=> %m%n log4j.logger.errorout=debug,A6 log4j.appender.A6=org.apache.log4j.DailyRollingFileAppender log4j.appender.A6.file=log_error_out log4j.appender.A6.DatePattern='.'yyyy-MM-dd log4j.appender.A6.layout=org.apache.log4j.PatternLayout log4j.appender.A6.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] Method:%l %n-=> %m%n log4j.logger.infoout=debug,A8 log4j.appender.A8=org.apache.log4j.DailyRollingFileAppender log4j.appender.A8.file=log_info_out log4j.appender.A8.DatePattern='.'yyyy-MM-dd log4j.appender.A8.layout=org.apache.log4j.PatternLayout log4j.appender.A8.layout.ConversionPattern=[%-5p] [%d{yyyy-MM-dd HH:mm:ss}] -=> %m%n iboss.log4j.logfile.path=F:\plat\webapp\intf_ibss\log //log日志地址
------解决方案--------------------
不会,up
------解决方案--------------------
一般只用循环日志,保存5份
------解决方案--------------------
up
------解决方案--------------------
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class Log4jTest {
private static final Log logger = LogFactory.getLog(Log4jTest.class);
public static void main(String[] args) {
org.apache.log4j.PropertyConfigurator.configure("src/log4j2.properties");
logger.info("xxxxxxx");
}
}
刚试过,可用.
log4j2.properties放在src下面
------解决方案--------------------