1 Reply Latest reply on Sep 20, 2017 1:26 PM by gir489

    Does Wildfly ignores the log4j2.xml config?

    cwansart

      Hello,

       

      I am using slf4j and log4j for logging, and I deploy on a Wildfly 10 server.

       

      I wanted to change the logging pattern project wide, not via the standalone.xml, but the log4j2.xml, as explained the log4j configuration documentation[1], was not taken into account.

      Now I am using the following jboss-log4j.xml which works:

       

      <?xml version="1.0" encoding="ISO-8859-1"?>
      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
      
      
      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
      
      
        <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
          <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
          <param name="Target" value="System.out"/>
          <param name="Threshold" value="ALL"/>
      
      
          <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="MYLOG -------- %d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
          </layout>
        </appender>
      
      
        <root>
          <appender-ref ref="CONSOLE"/>
        </root>
      
      
      </log4j:configuration>
      

       

      My guess is, that Wildfly simply ignores the log4j specific files, is that correct? So I probably have to use the jboss/wildfly specific ones, right?

       

      Thanks in advance!

       

      [1] Log4j – Configuring Log4j 2 - Apache Log4j 2

        • 1. Re: Does Wildfly ignores the log4j2.xml config?
          gir489

          Logging Configuration - WildFly 10 - Project Documentation Editor

          It appears Wildfly 10 only supports the log4j.xml format, as I don't see log4j2.xml in the list. I'd also recommend using log4j as a META-INF\MANIFEST.MF dependency, since Wildfly already has a logging framework, there's no reason for your app to carry around one, too.

          Per-deployment Logging

          Per-deployment logging allows you to add a logging configuration file to your deployment and have the logging for that deployment configured according to the configuration file. In an EAR the configuration should be in the META-INF directory. In a WAR or JAR deployment the configuration file can be in either the META-INF or WEB-INF/classes directories.

          The following configuration files are allowed:

          • logging.properties
          • jboss-logging.properties
          • log4j.properties
          • log4j.xml
          • jboss-log4j.xml