2.web项目的话,在容器里面可以找到,如:tomcat,jBoss等
3 log4j的话,在配置文件中指定的是哪里,就是哪里
此文档放在项目编译文件.class相同的位置### set log levels ###log4j.rootLogger = debug , stdout , D### 输出到控制台 ###log4j.appender.stdout = org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.Target = System.outlog4j.appender.stdout.layout = org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern = %d{ABSOLUTE} %5p %c{1}:%L - %m%n### 输出到日志文件 ###log4j.appender.D = org.apache.log4j.DailyRollingFileAppenderlog4j.appender.D.File = logs/log.loglog4j.appender.D.Append = truelog4j.appender.D.Threshold = DEBUGlog4j.appender.D.layout = org.apache.log4j.PatternLayoutlog4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n### 保存异常信息到单独文件 ###log4j.appender.D = org.apache.log4j.DailyRollingFileAppenderlog4j.appender.D.File = logs/error.loglog4j.appender.D.Append = truelog4j.appender.D.Threshold = ERRORlog4j.appender.D.layout = org.apache.log4j.PatternLayoutlog4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
配置获取方法:
PropertyConfigurator.configure( "D:\\Project Files\\myeclipse\\commontest\\bin\\log\\log4j\\log4j.properties" )
Logger log=Logger. getLogger(TestLog4j.class)
log.warn( "嘿嘿")
log.debug( "呜呜")
log.error( "错啦")
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)