In my WAR I want to have my own settings using log4j.properties
(located in WEB-INF/classes
). Per-deployment logging as described here does not work, namely JBoss does not log anything from my application. My simple app (to reproduce the problem) contains:
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
where LoggingContextListener
just logs some random strings.
log4j.properties
contains:
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
Anyone encountered similar issue?
Do you know if it's fixable? How?
In order to avoid confusions about the logging threshold here's the body of the 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?");
When I remove log4j.properties
from the classpath I get:
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?
but these logs come directly from JBoss logger configured in standalone.xml
- not what I want.