0 Replies Latest reply on Sep 24, 2013 3:47 AM by Przemyslaw Bielicki

    JBoss 7.2 per-deployment logging does not work with slf4j and log4j

    Przemyslaw Bielicki Newbie

      According to JBoss documentation when you provide log4j.properties JBoss should respect such settings - https://docs.jboss.org/author/display/AS72/Logging+Configuration#LoggingConfiguration-PerdeploymentLogging


      I created a simple application to reproduce the issue. Settings from log4.properties (located in WEB-INF/classes) are ignored. Basically, nothing is logged from the context listener shown below (not even System.err). When I remove log4j.properties I see the logs but settings are taken from standalone.xml - definitely not what I was expecting.


      Does anyone know why it does not work? Am I missing something?


      Simple app in question:



      public class LoggingContextListener implements ServletContextListener {


        public void contextInitialized(ServletContextEvent sce) {

          System.err.println("Trying to log something using SLF4J-Log4J");

          org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());


          logger.warn("anybody home?");

          logger.info("can you hear me?");


          System.err.println("Did you notice any logs?");




        public void contextDestroyed(ServletContextEvent sce) {




      with the following log4j.properties:


      log4j.rootLogger=WARN, stdout




      log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


      and pom.xml:








        <name>Logging in JBoss 7.2</name>
































                <!-- Support Servlet 3.x and higher -->







      BTW. Logs after removing log4j.properties:

      09:45:14,578 ERROR [stderr] (ServerService Thread Pool -- 54) Trying to log something using SLF4J-Log4J

      09:45:14,582 ERROR [logging.LoggingContextListener] (ServerService Thread Pool -- 54) Hello

      09:45:14,582 WARN  [logging.LoggingContextListener] (ServerService Thread Pool -- 54) anybody home?

      09:45:14,582 INFO  [logging.LoggingContextListener] (ServerService Thread Pool -- 54) can you hear me?

      09:45:14,582 ERROR [stderr] (ServerService Thread Pool -- 54) Did you notice any logs?

      09:45:14,756 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Deployed "logging-jboss-1.0.war" (runtime-name : "logging-jboss-1.0.war")


      Message was edited by: Przemyslaw Bielicki