3 Replies Latest reply on Oct 28, 2013 5:45 PM by jamezp

    Log4j Logging in a module

    kotinao7

      Hi,

      I want to create a module for my jboss application server 7.1.1.

      Here is my module.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <module xmlns="urn:jboss:module:1.0" name="ecard.hsm">
        <resources>
          <resource-root path="hsm.jar"/>
        </resources>
        <dependencies>
          <module name="org.jboss.log4j.logmanager"/>
          <module name="org.slf4j"/>
          <module name="org.jboss.logging"/>
          <module name="my.iaik"/>
          <module name="org.jboss.logmanager" services="import"/>
        </dependencies>
      </module>
      
      

       

      My Application code:

      import org.apache.log4j.Logger;
      ...
        private static final Logger LOG = Logger.getLogger(DelegationProvider.class.getName());
        LOG.error("log me");
      
      

       

      It seems that the log messages is lost anywhere, and is not redirected to the application server?

       

      Have I done anything wrong?

       

      Thank you for your help!

        • 1. Re: Log4j Logging in a module
          indranil32

          <module name="org.jboss.logging"/> -- This is enough for dependency. Please remove the others are test it.

          1 of 1 people found this helpful
          • 2. Re: Log4j Logging in a module
            kotinao7

            Thx for your hint!

             

            I am using Log4j in the module, so I get a ClassDefFoundError.

             

            java.lang.NoClassDefFoundError: org/apache/log4j/Logger

            at.provider.DelegationProvider.<clinit>(DelegationProvider.java:41)

            at.test.TestServlet.doGet(TestServlet.java:34)

            javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

            javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

            • 3. Re: Log4j Logging in a module
              jamezp

              If you're only using log4j, then that's all you need to import is org.apache.log4j.

               

              For why the logs aren't showing up. Are you attempting to configure the log4j log manager in your code? Also do you have a log4j configuration file in your module?

               

              --

              James R. Perkins