1 2 Previous Next 15 Replies Latest reply on Jun 22, 2013 9:33 AM by alex.alvarez.

    Logging in JBoss AS 7.1.3.Final within EAR

    fcorneli

      Hi,

       

      There seems to be something wrong with logging from within an EAR. Sometimes it works, sometimes it doesn't. And I cannot seem to find a pattern when and when not.

      I've tried different logging frameworks: commons-logging, jboss-logging, java logging.

      Creating an EAR with a WAR containing a servlet gives me logging as expected. I.e., I create the following within standalone-full.xml subsystem xmlns="urn:jboss:domain:logging:1.1":

                   <periodic-rotating-file-handler name="MYLOGGER">
                      <level name="DEBUG"/>
                      <formatter>
                          <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                      </formatter>
                      <file relative-to="jboss.server.log.dir" path="mylogger.log"/>
                      <suffix value=".yyyy-MM-dd"/>
                      <append value="true"/>
                  </periodic-rotating-file-handler>
                  <logger category="my.package" use-parent-handlers="false">
                      <level name="DEBUG"/>
                      <handlers>
                          <handler name="MYLOGGER"/>
                      </handlers>
                  </logger>
      

       

      When using:

       

      Log LOG = LogFactory.getLog(MyServlet.class);
      LOG.debug("hello world");
      

       

      I indeed get "hello world" within "mylogger.log". But doing the same from within a CDI or EJB3 bean doesn't give me any logging at all. Logging from within the model EJB JAR doesn't work either.

       

      Anyone else experiencing weird logging behaviour when using an EAR setup?

       

      Already played with several jboss-deployment-structure.xml configs, nothing seems to give the expected behaviour.

        • 1. Re: Logging in JBoss AS 7.1.3.Final within EAR
          jamezp

          Do you have a logging configuration file in your EAR?

           

          --

          James R. Perkins

          • 2. Re: Logging in JBoss AS 7.1.3.Final within EAR
            fcorneli

            No, I have no logging configuration within my EAR at all. I've already tried adding commons-logging-api to the WARs, EAR/lib, even no commons-logging-api at all, but in that case with a jboss-deployment-structure.xml under EAR/META-INF containing:

             

            <jboss-deployment-structure>
                <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
                <deployment>
                    <dependencies>
                        <module name="org.apache.commons.logging" />
                        <module name="org.jboss.logging"/>
                        <module name="org.jboss.logmanager" />
                        <module name="javax.faces.api"/>
                    </dependencies>
                </deployment>
            </jboss-deployment-structure>
            

             

            None of these configs give me a working logging. It's really weird. I'm at Devoxx this week, so if anyone feels tempted to try this one out on my machine, please be my guest...

            • 3. Re: Logging in JBoss AS 7.1.3.Final within EAR
              fcorneli

              I've tried this out on JBoss AS 7.1.1.Final and JBoss AS 7.1.2.Final. Seems like this is a regression starting from JBoss AS 7.1.2.Final.

              • 4. Re: Logging in JBoss AS 7.1.3.Final within EAR
                jamezp

                If there is no logging configuration file in your deployment, the only other thing I can think of is the categories aren't matching up. If you're using the Class<?> static factory method, then your package would need to the be same as your category in the configuration.

                 

                Log LOG = LogFactory.getLog(MyServlet.class);
                

                 

                Should be the equivalent of:

                Log LOG = LogFactory.getLog(MyServlet.class.getName());
                

                 

                --

                James R. Perkins

                • 5. Re: Logging in JBoss AS 7.1.3.Final within EAR
                  fcorneli

                  I also checked the category names.

                  • 6. Re: Logging in JBoss AS 7.1.3.Final within EAR
                    jamezp

                    I modified the ejb-in-ear quickstart to log a debug message and it seemed to work for me. Is there a sample application/source you could attach?

                     

                    --

                    James R. Perkins

                    • 7. Re: Logging in JBoss AS 7.1.3.Final within EAR
                      fcorneli

                      Unfortunately this one is closed source. The EAR contains a model EJB JAR (EJB/JPA), an admin portal WAR (CDI/JSF/Primefaces), an end-user portal WAR (CDI/JSF/PrimeFaces), a RESTy web service WAR (CDI/JSF/PrimeFaces/JAX-RS), and a demo web portal WAR (CDI/JSF/PrimeFaces). But anyway, I'll try to strip down the application and see from which point it starts to go wrong.

                      • 8. Re: Logging in JBoss AS 7.1.3.Final within EAR
                        fcorneli

                        mmm... just a WAR within the EAR gives me logging in both servlets and CDI via commons-logging, jboss-logging and java util logging. Adding the following dependency under EAR/lib and I already lose some logging:

                         

                        <dependency>
                                    <groupId>org.apache.ws.security</groupId>
                                    <artifactId>wss4j</artifactId>
                                    <version>1.6.4</version>
                        </dependency> 
                        

                         

                        wss4j depends on opensaml -> ... -> slf4j, although not included in the actual EAR. Adding "org.slf4j" as module dependency to META-INF/jboss-deployment-structure.xml didn't work for me.

                         

                        Getting logging in Java EE enabled under JBoss AS shouldn't be this hard, no?

                        • 9. Re: Logging in JBoss AS 7.1.3.Final within EAR
                          jamezp

                          No, not at all. Especially with 7.1.3 and higher. It should just work. You shouldn't have to exclude or include any of the major logging libraries. I'll give it some testing in the morning and post the results back here.

                           

                          --

                          James R. Perkins

                          • 10. Re: Logging in JBoss AS 7.1.3.Final within EAR
                            jamezp

                            One possible thought, try adding the org.jboss.as.logging.per-deployment=false system property. Maybe that library has a logging configuration file in it which is changing/disabling your logging.

                             

                            --

                            James R. Perkins

                            • 11. Re: Logging in JBoss AS 7.1.3.Final within EAR
                              fcorneli

                              It seems really tricky to keep the logging stable. As soon as I use a dependency that JBoss also offers as module (for example joda-time), I run into trouble. Excluding the dependency and declaring the module in jboss-deployment-structure.xml helps. But I guess this is not maintainable as some of my dependencies conflict with the versions of these provided by JBoss AS modules.

                              • 12. Re: Logging in JBoss AS 7.1.3.Final within EAR
                                jaikiran

                                Would it be possible for you to create a simple application which reproduces this? It shouldn't be this hard to setup logging for an application.

                                • 13. Re: Logging in JBoss AS 7.1.3.Final within EAR
                                  alex.alvarez.

                                  I am having a similar issue, when I debug I can navigate to the parent logger but it does not have the right handlers (which I have configured in standalone.xml), if i use the web console i can see that the logging configuration is correct.   My deployment-structure looks like this:

                                   

                                   

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

                                  <jboss-deployment-structure>

                                      <deployment>

                                          <exclusions>

                                              <module name="org.apache.commons.io" />

                                              <module name="org.apache.commons-fileupload" />

                                          </exclusions>

                                   

                                          <dependencies>

                                              <module name="org.slf4j" export="true" />

                                              <module name="org.slf4j.ext" export="true" />

                                              <module name="org.jboss.logging" export="true" />

                                          </dependencies>

                                      </deployment>

                                  </jboss-deployment-structure>

                                  • 14. Re: Logging in JBoss AS 7.1.3.Final within EAR
                                    jamezp

                                    Do you have a logging configuration file in your deployment by chance? You could try setting the org.jboss.as.logging.per-deployment system property to false to see if that solves your issue.

                                     

                                    --

                                    James R. Perkins

                                    1 2 Previous Next