title: Log4J2 is not creating log files in JBOSS 7.2.8 in multi JVM, multi app setup, however LOG4J did
body: <p>The Log4J 1.2.17 had been working correctly. Once switched to Log4J2, the logging works on local JBOSS 7.1 server (laptop), creating logs as it should. Once deployed to multi JVM/multi application environment, logging seems to initialize, but logs are not populated. Similar setup with LOG4J 1.2.17 worked.</p>
  <p>The setup: JBOSS 7.2.8 has 3 JVMS, each runs its own application. Each application has its own Log4J version.</p>
  <p>My application has log4j2 jars located within the war library:</p>
  <pre><code>MyAppWeb/WebContent/WEB-INF/lib/log4j-api-2.17.1.jar
  MyAppWeb/WebContent/WEB-INF/lib/log4j-core-2.17.1.jar 
  MyAppWeb/WebContent/WEB-INF/lib/log4j-slf4j-impl-2.17.1.jar 
  MyAppWeb//WebContent/WEB-INF/lib/slf4j-api-1.7.5.jar
  </code></pre>
  <p>Log4j2.properties file under srs/ver/resources</p>
  <pre><code>name = Log4j2PropertiesConfig
   
  property.filePath = /appllogs/mds
   
  #appenders
  appenders = mdslogappender, ftclogappender, console
  
  #appender for mds application log
  appender.mdslogappender.type = RollingFile
  appender.mdslogappender.name = MDSLOGFILE
  appender.mdslogappender.fileName = ${filePath}/application.log
  appender.mdslogappender.filePattern = ${filename}-backup-%d{MM-dd-yy-HH-mm-ss}.log
  appender.mdslogappender.layout.type = PatternLayout
  appender.mdslogappender.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} [%X{userId}] %5p %c{1}:%L - %m%n
  appender.mdslogappender.policies.type = Policies
  # To change log file after 20Mb size
  appender.mdslogappender.policies.size.type = SizeBasedTriggeringPolicy
  appender.mdslogappender.policies.size.size=20MB
  appender.mdslogappender.strategy.type = DefaultRolloverStrategy
  appender.mdslogappender.strategy.max = 20
   
  #appender for ftc mds log 
  appender.ftclogappender.type = RollingFile
  appender.ftclogappender.name = FTCLOGFILE
  appender.ftclogappender.fileName=${filePath}/ftcmds.log
  appender.ftclogappender.filePattern = ${filename}-backup-%d{MM-dd-yy-HH-mm-ss}.log
  appender.ftclogappender.layout.type = PatternLayout
  appender.ftclogappender.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} [%X{userId}] %5p %c{1}:%L - %m%n
  appender.ftclogappender.policies.type = Policies
  # To change log file after 20Mb size
  appender.ftclogappender.policies.size.type = SizeBasedTriggeringPolicy
  appender.ftclogappender.policies.size.size=20MB
  appender.ftclogappender.strategy.type = DefaultRolloverStrategy
  appender.ftclogappender.strategy.max = 20
  
  
  # STDOUT appender
  appender.console.type=Console
  appender.console.name=STDOUT
  appender.console.layout.type=PatternLayout
  appender.console.layout.pattern=%d{yyyy-MM-dd HH:mm:ss} [%X{userId}] %5p %c{1}:%L - %m%n
  
  
  #loggers
  loggers = mdsfilelogger, ftcfilelogger, mdsappfilelogger
  
  
  #logger for mds components application 
  logger.mdsfilelogger.name = com.xxx.yyy.components.mds
  logger.mdsfilelogger.level = error
  logger.mdsfilelogger.additivity = false
  logger.mdsfilelogger.appenderRefs = mdslogappender
  logger.mdsfilelogger.appenderRef.mdslogappender.ref = MDSLOGFILE
  
  #logger for mds app log
  logger.mdsappfilelogger.name = com.xxx.mds.ui
  logger.mdsfimdsappfileloggerlelogger.level = error
  logger.mdsappfilelogger.additivity = false
  logger.mdsappfilelogger.appenderRefs = mdslogappender
  logger.mdsappfilelogger.appenderRef.mdslogappender.ref = MDSLOGFILE
  
  #logger for mds ftc log
  logger.ftcfilelogger.name=com.xxx.mds.ui.ftc
  logger.ftcfilelogger.level = info
  logger.ftcfilelogger.additivity = false
  logger.ftcfilelogger.appenderRefs = ftclogappender
  logger.ftcfilelogger.appenderRef.ftclogappender.ref = FTCLOGFILE
  
  
  rootLogger.level = error, MDSLOGFILE
  
  </code></pre>
  <p><strong>The log intantiated in Log4JInit.java class</strong></p>
  <p>**** Log4JInit.java class ****</p>
  <pre><code>package com.xxx.mds.ui.config;
  
  import java.io.File;
  import java.io.FileInputStream;
  
  import javax.servlet.http.HttpServlet;
  
  import org.apache.logging.log4j.core.config.ConfigurationSource;
  import org.apache.logging.log4j.core.config.Configurator;
  import org.slf4j.LoggerFactory;
  
  
  @SuppressWarnings(&quot;serial&quot;)
  public class Log4jInit extends HttpServlet {
      public void init() {
          System.out.println( &quot;*** Init MDSAppWeb Log4J&quot; );
          try {
              String prefix = getServletContext().getRealPath(&quot;/&quot;);
              //PropertyConfigurator.configure(prefix+&quot;/WEB-INF/classes/log4j.properties&quot;);       
              String propertiesFile = prefix+&quot;/WEB-INF/classes/log4j2.properties&quot;;  
              ConfigurationSource source = new ConfigurationSource(new FileInputStream(propertiesFile), new File(propertiesFile));
              Configurator.initialize(null, source);
              
              LoggerFactory.getLogger(Log4jInit.class).info( &quot;*** SUCCESS Init MDSAppWeb Log4J&quot; );    
          } catch (Exception e) {
              System.err.println( &quot;*** FAILED Init MDSAppWeb Log4J&quot; );
              e.printStackTrace();
          }
          
      }
  }
  </code></pre>
  <p>When server starts it registers initialization in console:</p>
  <pre><code>11:18:35,642 INFO  [stdout] (ServerService Thread Pool -- 100) *** Init PBRAppWeb Log4J
  </code></pre>
  <p>I added the jboss-deployment-structure.xml to the war file of application to omit JBOSS logging.</p>
  <pre><code>&lt;jboss-deployment-structure&gt;
      &lt;deployment&gt;
      &lt;exclusions&gt;
          &lt;module name=&quot;org.apache.logging.log4j.api&quot; /&gt;
          &lt;module name=&quot;org.apache.commons.logging&quot; /&gt;
          &lt;module name=&quot;org.slf4j&quot; /&gt;
          &lt;module name=&quot;org.slf4j.impl&quot; /&gt;
          &lt;module name=&quot;org.jboss.logging&quot; /&gt;
          &lt;module name=&quot;org.jboss.logging.jul-to-slf4j-stub&quot; /&gt;
          &lt;module name=&quot;org.jboss.logmanager&quot; /&gt;
          &lt;module name=&quot;org.jboss.logmanager.log4j&quot; /&gt;
      &lt;/exclusions&gt;
      &lt;/deployment&gt;
      
  &lt;/jboss-deployment-structure&gt;
  </code></pre>
  <p>I also added recommended variable to JBOSS as well:</p>
  <p>``
  Add system property in JVM level that “org.jboss.as.logging.per-deployment=false”</p>
  <p>Under profile logging subsystem add “add-logging-api-dependencies=false”
  ``</p>
  <p><strong>Still - no logs are generated</strong></p>
  <p>Please help.</p>