Per-deployment logging in 7.2 AS does not seem to work (link to sample app attached)
jrmihalick Sep 26, 2013 2:15 PMI believe that I have followed all of the instructions properly as defined at https://docs.jboss.org/author/display/AS72/Logging+Configuration#LoggingConfiguration-PerdeploymentLogging . I have a super simple 'log4jtest.war' app using log4j as my implementation. I have my log4j.properties file located in WEB-INF/classes, I have log4j-1.2.16.jar in my WEB-INF/lib dir. When I deploy the application and hit my servlet or JSP which include logger calls, I don't get any logging whatsoever. I attempted this on a fresh install of JBoss EAP 6.1.0
My log4j.properties:
log4j.rootLogger=DEBUG,CONSOLE,log4jtest
# Console appender
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %5p [%t] %c - %m%n
# log4jtest Rolling File appender
log4j.appender.log4jtest=org.apache.log4j.RollingFileAppender
log4j.appender.log4jtest.threshold=TRACE
log4j.appender.log4jtest.File=log/log4jtest.log
log4j.appender.log4jtest.MaxFileSize=9000KB
log4j.appender.log4jtest.MaxBackupIndex=3
log4j.appender.log4jtest.layout=org.apache.log4j.PatternLayout
log4j.appender.log4jtest.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %-5p - %m%n
Download source and war
You can download my sample app source in zip format from: http://bit.ly/16A3w3T
The application is a maven build with pom.xml file included. I built with Java 1.6.
You can download my sample app war from: http://bit.ly/1b6sZam
Once you deploy the app:
To test logging from the servlet, hit: http://localhost:8080/log4jtest/log4jtest
To test logging from the JSP, hit: http://localhost:8080/log4jtest
I will be happy to file a JIRA ticket on this if that's what's needed. Thanks for your help on this.
UPDATE (9/26/2013)
It appears that if you exclude the log4j jar from your WEB-INF/lib directory, it starts working. However, if you try to manipulate the log level at runtime using the Log4J APIs, it seems to have no effect (for example, to change the root log level). Has anyone else gotten per deployment logging to work by excluding the log4j jar file from your deployment?
(I will note that the JBoss documentation does not mention that the log4j jar file should be excluded. It's easily assumed that the log4 jar should be present in your WEB-INF/lib since the jar file will be necessary for compiling your app if you are using the log4j API directly in your app.)