3 Replies Latest reply on Dec 10, 2015 8:44 PM by James Perkins

    Issues with log4j logging to console on wildfly (partially solved)

    Bruno Conrad Newbie

      Hi,

      I've been able to use log4j to log to the console but am still seeing some non-standard output. I was able to get logging to work by adding jboss-deployment-structure.xml to WEB-INF (below). I also added log4j dependency to my pom.  I am seeing my log messages but they appear to be wrapped by jboss logging. As you can see in the second message below, there are two time stamps and log levels. The first are from jboss, the second are mine. I can get rid of mine which will eliminate the duplication but still wondering what is going on and want to make sure I have control over log levels and what is getting logged.

       

      Messages:

      23:43:11,076 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015960: Class Path entry activation.jar in /C:/apps/accurevWorkspace/syme/jaxrs-endpoint/target/syme-war/WEB-INF/lib/mail-1.4.jar  does not point to a valid jar for a Class-Path reference.

      23:43:11,599 INFO [stdout] (MSC service thread 1-11) 23:43:11 INFO  StartupServletContextListener.contextInitialized ********************************** Start SYME at Wed Dec 09 23:43:11 PST 2015

       

      jboss-deployment-structure.xml

       

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

         <deployment>

         <exclusions>

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

         </exclusions>

         <exclude-subsystems>

         <subsystem name="logging" />

         </exclude-subsystems>

         </deployment>

      </jboss-deployment-structure>



      log4j.properties


      logDirectory=./
      logFile=SYME.log
      logLevel=DEBUG

      to=baconrad@ultramondo.com
      from=syme@syme.com
      subject=SYME Error - (Domain)Instance DEFAULT
      logOutput=CONSOLE, FILE

      # ---- Set the Log Level from properties which can be reset by JFig ---
      log4j.rootLogger=DEBUG, CONSOLE, FILE
      ###################
      # Console Appender
      ###################
      log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
      log4j.appender.Threshold=DEBUG
      log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
      log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}.%M %m%n

      ##################### 
      # File Appender
      ##################### 
      log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
      log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
      log4j.appender.FILE.File=${logDirectory}${logFile}
      log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
      log4j.appender.FILE.layout.ConversionPattern=%d %-5p %c{1}.%M - %m%n


      log4j.appender.File=${jboss.server.log.dir}/root.log
      log4j.appender.RootFileAppender.File=${jboss.server.log.dir}/root2.log
      log4j.appender.PrivateLog4JOnJBossFileAppender=org.apache.log4j.RollingFileAppender
      log4j.appender.PrivateLog4JOnJBossFileAppender.File=${jboss.server.log.dir}/PrivateLog4JOnJBoss.log
      log4j.appender.PrivateLog4JOnJBossFileAppender.maxBackupIndex=10
      log4j.appender.PrivateLog4JOnJBossFileAppender.maxFileSize=10MB
      log4j.appender.PrivateLog4JOnJBossFileAppender.layout=org.apache.log4j.PatternLayout
      log4j.appender.PrivateLog4JOnJBossFileAppender.layout.ConversionPattern=Date: %d{dd MMM yyyy HH:mm:ss,SSS}\nSeverity: %p\nCategory: %c\nClass: %C [%M - %L]\nMessage: %m%n\n
      #####################
      # Log Levels
      ##################### 
      log4j.logger.javax=INFO
      log4j.logger.com=INFO
      log4j.logger.net=WARN
      log4j.logger.org=INFO
      log4j.logger.sax=INFO
      log4j.logger.org.igfay.syme=DEBUG