【发布时间】:2013-09-29 08:04:00
【问题描述】:
在我的 WAR 中,我想使用 log4j.properties(位于 WEB-INF/classes)进行自己的设置。 here 所述的每次部署日志记录不起作用,即 JBoss 不会从我的应用程序中记录任何内容。我的简单应用(重现问题)包含:
WEB-INF/classes/log4j.properties
WEB-INF/classes/logging/LoggingContextListener.class
WEB-INF/lib/log4j-1.2.17.jar
WEB-INF/lib/slf4j-api-1.7.5.jar
WEB-INF/lib/slf4j-log4j12-1.7.5.jar
LoggingContextListener 只记录一些随机字符串。
log4j.properties 包含:
log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
有人遇到过类似的问题吗?
你知道它是否可修复吗?怎么样?
为了避免对日志记录阈值造成混淆,这里是 LoggingContextListener 的正文
System.err.println("Trying to log something using SLF4J-Log4J");
org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());
logger.error("Hello");
logger.warn("anybody home?");
logger.info("can you hear me?");
logger.debug("WTF?");
System.err.println("Did you notice any logs?");
当我从类路径中删除 log4j.properties 时,我得到:
ERROR [stderr] (ServerService Thread Pool -- 54) Trying to log something using SLF4J-Log4J
ERROR [logging.LoggingContextListener] (ServerService Thread Pool -- 54) Hello
WARN [logging.LoggingContextListener] (ServerService Thread Pool -- 54) anybody home?
INFO [logging.LoggingContextListener] (ServerService Thread Pool -- 54) can you hear me?
ERROR [stderr] (ServerService Thread Pool -- 54) Did you notice any logs?
但这些日志直接来自 standalone.xml 中配置的 JBoss 记录器 - 这不是我想要的。
【问题讨论】:
标签: java logging jboss log4j slf4j