Application Server 3  4  5 and 6
  1. Application Server 3 4 5 and 6
  2. JBAS-8791

log4j-appender seems not working in jboss-logging (AS6 final)

    Details

    • Similar Issues:
      Show 10 results 

      Description

      We are using some custom logger based on log4j appenders. I made a jboss-logging.xml configuration but it seems that my log4j-appender doesn't log anything. I'm working in AS6 final version.

      I made an example with a standard log4j appender (neither working). The category "com.sample" should be managed by the log4jappender. Every second the bean should write something, but nothing happens, the log file is not even created. I tried with other log4j loggers/ custom loggers and no success.

      When activating CONSOLE handler the logs are correctly written in console, but when only using the log4j-appender nothing happens after server started.

      The configuration file seems correct , but can't unfortunately check it against a documentation yet.

      ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      <logging xmlns="urn:jboss:logging:6.0" xmlns:b="urn:jboss:bean-deployer:2.0">

      <!-- ================================= -->
      <!-- Preserve messages in a local file -->
      <!-- ================================= -->

      <!-- A time/date based rolling handler -->

      <periodic-rotating-file-handler
      file-name="$

      {jboss.server.log.dir}/server.log"
      name="FILE"
      autoflush="true"
      append="true"
      suffix=".yyyy-MM-dd"> <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->

      <error-manager>
      <only-once/>
      </error-manager>

      <formatter>
      <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->
      <!-- Uncomment this to get the class name in the log as well as the category
      <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>
      -->
      <!-- Uncomment this to log without the class name in the log -->
      <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
      </formatter>
      </periodic-rotating-file-handler>

      <!-- ============================== -->
      <!-- Append messages to the console -->
      <!-- ============================== -->

      <console-handler name="CONSOLE" autoflush="true" target="System.out">
      <error-manager>
      <only-once/>
      </error-manager>

      <level name="INFO"/>

      <formatter>
      <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n"/>
      </formatter>
      </console-handler>


      <log4j-appender name="Log4jAppender" class="org.apache.log4j.DailyRollingFileAppender">
      <error-manager>
      <only-once/>
      </error-manager>

      <level name="DEBUG"/>

      <properties>
      <!-- <property name="directory">${jboss.server.log.dir}

      /</property> -->
      <property name="file">$

      {jboss.server.log.dir}

      /log4j.log</property>
      <property name="append">true</property>
      <property name="datePattern">'.'yyyy-MM-dd</property>
      </properties>

      <formatter>
      <pattern-formatter pattern="%d %-5p [%c] %m%n"/>
      </formatter>

      </log4j-appender>

      <logger category="com.sample">
      <level name="DEBUG"/>
      <handlers>
      <handler-ref name="Log4jAppender"/>
      </handlers>
      </logger>

      <!-- ======================= -->
      <!-- Setup the Root category -->
      <!-- ======================= -->

      <root-logger>
      <!-- Set the root logger priority via a system property, with a default value. -->
      <level name="$

      {jboss.server.log.threshold:INFO}

      "/>
      <handlers>
      <handler-ref name="Log4jAppender"/>

      <!--
      <handler-ref name="CONSOLE"/>
      <handler-ref name="FILE"/>
      -->
      </handlers>
      </root-logger>

      </logging>
      ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      package com.sample;

      import javax.ejb.Schedule;
      import javax.ejb.Stateless;

      import org.apache.log4j.Logger;

      //@Singleton
      @Stateless
      public class TestBean {

      public static final Logger LOG = Logger.getLogger(TestBean.class);

      public TestBean()

      { System.out.println("TestBean is instantiated and should write someting in the log file"); LOG.info("This is information log"); }

      @Schedule(second="/1", minute="",hour="*", persistent=false)
      public void writeSomething()

      { System.out.println("This should write something in the log file at scheduled times"); LOG.info("This is scheduled information log"); }

      }

        Issue Links

          Activity

          Hide
          jaikiran pai
          added a comment -

          Marking for 6.1.0, so that it can tracked accordingly.

          Show
          jaikiran pai
          added a comment - Marking for 6.1.0, so that it can tracked accordingly.
          Hide
          jaikiran pai
          added a comment -

          r111767 commit upgraded log4j to 1.2.16 version (along with other logging fixes) and that should fix this issue. To test the fix, the nightly builds are available here http://community.jboss.org/thread/161386

          Marking this as resolved. Please reopen if it's still an issue.

          Show
          jaikiran pai
          added a comment - r111767 commit upgraded log4j to 1.2.16 version (along with other logging fixes) and that should fix this issue. To test the fix, the nightly builds are available here http://community.jboss.org/thread/161386 Marking this as resolved. Please reopen if it's still an issue.
          Hide
          Dmitry Oparin
          added a comment -

          It seems that distribution of 6.1.0 doesn't include jars, attached to this issue.
          Using of SMTPAppender recursively produces

          ERROR [STDERR] log4j:ERROR Message object not configured.
          

          with StackOverflowError at the end. The reason is that activateOptions() of appender is not called.

          The problem disappears when jars in distribution of 6.1.0 are replaced with jars, attached to the issue.

          Show
          Dmitry Oparin
          added a comment - It seems that distribution of 6.1.0 doesn't include jars, attached to this issue. Using of SMTPAppender recursively produces ERROR [STDERR] log4j:ERROR Message object not configured. with StackOverflowError at the end. The reason is that activateOptions() of appender is not called. The problem disappears when jars in distribution of 6.1.0 are replaced with jars, attached to the issue.
          Hide
          denis kulikov
          added a comment -

          The patch partly fixed problem.
          If this patch wasn't fully applied, without adding jboss-logmanager.jar, it prones to works log4j loggers and appenders. But many stack trace falls in console about class not found LogManager.
          Also I turned off JBoss beans for logging in ..\deployers\jboss-logging.deployer\META-INF\logmanager-jboss-beans.xml.

          Show
          denis kulikov
          added a comment - The patch partly fixed problem. If this patch wasn't fully applied, without adding jboss-logmanager.jar, it prones to works log4j loggers and appenders. But many stack trace falls in console about class not found LogManager. Also I turned off JBoss beans for logging in ..\deployers\jboss-logging.deployer\META-INF\logmanager-jboss-beans.xml.
          Hide
          Stephan Tentrup
          added a comment -

          I was able to fix the problem by applying the patched logging-service-metadata.jar contained in the attachment to my JBoss 6.1.0 installation. The changes in jboss-logmanager-log4j.jar and jboss-logmanager.jar are already included in JBoss 6.1.0.

          Show
          Stephan Tentrup
          added a comment - I was able to fix the problem by applying the patched logging-service-metadata.jar contained in the attachment to my JBoss 6.1.0 installation. The changes in jboss-logmanager-log4j.jar and jboss-logmanager.jar are already included in JBoss 6.1.0.

            People

            • Assignee:
              David Lloyd
              Reporter:
              Gregoire Botquin
            • Votes:
              10 Vote for this issue
              Watchers:
              17 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: