1 Reply Latest reply on Oct 30, 2015 12:03 PM by jamezp

    wildfly cannot output log with my log4j configuation

    darouwan

      As the problem most people ever meet, the log of my web app is only printed within the log of wildfly. For DailyRollingFileAppender the log file is not existed at specific folder

       

      I have tried some way following instruction online. Here is my configuration.

      log4j.properties

       

      log4j.rootLogger=DEBUG,console,R

      log4j.appender.console=org.apache.log4j.ConsoleAppender
      log4j.appender.console.Threshold=DEBUG
      log4j.appender.console.ImmediateFlush=true
      log4j.appender.console.Target=System.out
      log4j.appender.console.layout=org.apache.log4j.PatternLayout
      log4j.appender.console.layout.ConversionPattern=[%p]\t%d [%t] %c:%m%n

      log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
      log4j.appender.R.MaxFileSize=10000KB
      log4j.appender.R.Threshold=DEBUG
      log4j.appender.R.MaxBackupIndex=5
      log4j.appender.R.File=/home/wiscom/logs/parking_service.log
      #log4j.appender.R.File=${catalina.home}/parking_service.log
      log4j.appender.R.layout=org.apache.log4j.PatternLayout
      log4j.appender.R.layout.ConversionPattern=[%p]\t%d [%t] %c:%m%n

      webapp/WEB-INF/jboss-deployment-structure.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

        <deployment>

        <exclusions>

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

        </exclusions>

        </deployment>

      </jboss-deployment-structure>

      and in standalone\configuration\standalone.xml , add

      standalone\configuration\standalone.xml

      under <subsystem xmlns="urn:jboss:domain:logging:3.0">, like this

      <profile>

              <subsystem xmlns="urn:jboss:domain:logging:3.0">

                  <use-deployment-logging-config value="false"/>

                  <console-handler name="CONSOLE">

                      <level name="INFO"/>

                      <formatter>

                          <named-formatter name="COLOR-PATTERN"/>

                      </formatter>

                  </console-handler>

      ...

       

      It was working in Tomcat, but daily rolling log file cannot been seen under specified directory. Can someone help me?

        • 1. Re: wildfly cannot output log with my log4j configuation
          jamezp

          You shouldn't need to exclude the org.apache.log4j module or change the use-deployment-logging-config to false. If this is a WAR deployment just put the log4j.properties in the WAR/WEB-INF/classes directory for an EAR it belongs in the EAR/META-INF directory. You also don't need to include a log4j library in your deployment.

           

          If you would rather use your own log4j library and keep the settings you have above you need to ensure that the log4j.properties is on your class path so log4j can see it.

           

          --

          James R. Perkins