0 Replies Latest reply on Jan 1, 2019 10:45 PM by Prabal Rakshit

    Unable to write application logs using externalized Log4j2 XML configuration using Wildfly 15

    Prabal Rakshit Newbie

      I have an application made of Spring Boot WAR packages that need to be migrated to Red Hat EAP 7.1.5 ( I am currently testing this against Wildfly though).



      In my current setup I do the following:



      1. Each WAR has a dedicated log4j2 XML per environment.

      2. This XML file name is defined in the web.xml

      3. The folder containing the log4j2_xxxx.xml is added to the classpath in the JVM startup script.

      4. The WARs are distributed across multiple run-time instances, with a possibility of one run-time hosting more than one WAR.



      I would like to replicate the same using EAP. I do see the external log4j2 XML configuration being successfully loaded, however do not see any log statements being written at all.



      I am using the following dependencies for packaging log4j2

      org.springframework.boot.spring-boot-starter-log4j2 (version 1.5.7)

      org.apache.logging.log4j.log4j-web (version 2.10.0)



      I have tried the following:



      1. Define a custom module under $JBOSS_HOME/modules/

      2. Add the log4j2 XML in the same folder.

      3. Refer this as global-module in standalone.xml



      When I deploy a WAR I can see that the expected log file is created, which means the log4j2 XML configuration is being read successfully. However no logs get written at all in the application log file.



      I have tried to get past this by defining a jboss-deployment-structure XML as follows:



          <?xml version="1.0" encoding="UTF-8"?>




          <module name="org.apache.log4j" />

          <module name="org.jboss.log4j.logmanager" />

          <module name="org.jboss.logging" />

          <module name="org.jboss.logging.commons.logging" />

          <module name="org.jboss.logging.jul-to-slf4j-stub" />



          <subsystem name="logging"/> 








      This results in the application logging being removed from the default JBOSS log (server.log) altogether but it does not write the logs to the designated log as well.



      I would expect all the logging being done within the application to be written into the file defined by the external log4j2 XML configuration. Any idea what I am missing?