NutzCN Logo
问答 log4j配置问题及Console信息保存
发布于 3016天前 作者 Hamming 6676 次浏览 复制 上一个帖子 下一个帖子
标签:

配置信息如下。我想把Console的信息都保存到日志log里面 该怎么设置呢 目前启动还有如下错误

#日志级别有:OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、ALL
log4j.rootLogger=ALL,Console,debug,BLUEJAY,RollingFile
log4j.category.org.nutz=debug, BLUEJAY
log4j.additivity.org.nutz=false

#Appenders ...
log4j.appender.BLUEJAY=org.apache.log4j.ConsoleAppender
log4j.appender.BLUEJAY.Threshold=debug
log4j.appender.BLUEJAY.file=../logs/BLUEJAY
log4j.appender.BLUEJAY.DatePattern='_'yyyyMMdd_HH'.txt'
log4j.appender.BLUEJAY.layout=org.apache.log4j.PatternLayout
log4j.appender.BLUEJAY.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

#控制台日志
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.Threshold=ALL
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%l]%m%n

#每小时生成一个日志文件
log4j.appender.RollingFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RollingFile.Threshold=ALL
log4j.appender.RollingFile.file=../logs/log
log4j.appender.RollingFile.DatePattern='_'yyyyMMdd_HH'.txt'
log4j.appender.RollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingFile.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%l]%m%n

启动报错

[INFO] No Transaction manager found - if your webapp requires one, please configure one.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
log4j:ERROR Could not find value for key log4j.appender.debug
log4j:ERROR Could not instantiate appender named "debug".
log4j:WARN No such property [file] in org.apache.log4j.ConsoleAppender.
log4j:WARN No such property [datePattern] in org.apache.log4j.ConsoleAppender.
2016-09-19 09:10:29,410 [main] INFO  org.nutz.mvc.NutSessionListener - NutIoc SessionScope is Enable.
[INFO] started o.m.j.p.JettyWebAppContext{/,file:/E:/project/bluejay/src/main/webapp/},file:/E:/project/bluejay/src/main/webapp/
5 回复
log4j.rootLogger=ALL,Console,debug,BLUEJAY,RollingFile
#改成
log4j.rootLogger=DEBUG,ALL,Console,BLUEJAY,RollingFile

另外, BLUEJAY的类型是ConsoleAppender,所以没有file和datePatten的

@wendal 莫非是log4j 版本的不同配置

  <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-log4j-appender</artifactId>
            <version>5.14.0</version>
        </dependency>

不清楚. 我只知道要用排除法.

出什么错.

添加回复
请先登陆
回到顶部