2 Replies Latest reply on Apr 16, 2015 6:21 AM by Thomas Becker

    Wildfly 8.2.0 application logging with logback

    Thomas Becker Newbie

      Hi everyone,

       

      I want my ear application to log via logback and use the logback.xml provided by the app. I found that I need to exclude the logging subsystem in jboss to use the logging jars provided in the application and I did it like so:

       

      <jboss-deployment-structure>
        <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
        <deployment>
        <dependencies>
        <module name="org.hibernate.search.orm" services="export" />
        </dependencies>
        <exclude-subsystems>
        <subsystem name="logging" />
        </exclude-subsystems>
        </deployment>
        <sub-deployment name="logiq-web.war">
        <dependencies>
        <module name="org.hibernate.search.orm" services="export" />
        </dependencies>
        <local-last value="true" />
        <exclude-subsystems>
        <subsystem name="logging" />
        </exclude-subsystems>
        </sub-deployment>
        <sub-deployment name="logiq-ejb.jar">
        <dependencies>
        <module name="org.hibernate.search.orm" services="export" />
        </dependencies>
        <exclude-subsystems>
        <subsystem name="logging" />
        </exclude-subsystems>
        </sub-deployment>
      </jboss-deployment-structure>

       

      However this just leads to the following NoClassDefFoundError:


      [2015-04-15 09:54:57,657] Artifact logiq-ear:ear: java.lang.Exception: {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"logiq-ear.ear/logiq-ejb.jar#logiq-pu\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"logiq-ear.ear/logiq-ejb.jar#logiq-pu\": java.lang.NoClassDefFoundError: org/jboss/logging/Logger

          Caused by: java.lang.NoClassDefFoundError: org/jboss/logging/Logger

          Caused by: java.lang.ClassNotFoundException: org.jboss.logging.Logger from [Module \"deployment.logiq-ear.ear:main\" from Service Module Loader]"}}

       

      What am I missing here? Or what am I doing wrong?

       

      Thx for any help!

       

      Cheers,

      Thomas


        • 1. Re: Wildfly 8.2.0 application logging with logback
          Jay SenSharma Master

          Hello Thomas,

           

          I tried something like following on WildFly 8.2 and it seems to be working fine in

           

           

          Test.ear

          ├── logback_SLFf4j_Demo.war

          │   ├── index.jsp

          │   └── WEB-INF

          │       ├── classes

          │       │   ├── logback.xml

          │       │   ├── servlets

          │       │   │   └── TestServlet.class

          │       │   └── TestServlet.java

          │       └── lib

          │           ├── logback-classic-1.1.2.jar

          │           ├── logback-core-1.1.2.jar

          │           └── slf4j-api-1.6.4.jar

          └── META-INF

              ├── application.xml

              └── jboss-deployment-structure.xml

           

           

           

          My "Test.ear/META-INF/jboss-deployment-structure.xml" looks like following where rather than excluding the subsystem logging i did the following:

           

          <jboss-deployment-structure>
                <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
                <deployment>
                       <dependencies>
                           <module name="org.hibernate.search.orm" services="export" />
                       </dependencies>
                       <exclusions>
                           <module name="org.slf4j" />
                           <module name="org.slf4j.impl" />
                       </exclusions>
                </deployment>
                <sub-deployment name="logback_SLFf4j_Demo.war">
                       <dependencies>
                           <module name="org.hibernate.search.orm" services="export" />
                       </dependencies>
                       <exclusions>
                           <module name="org.slf4j" />
                           <module name="org.slf4j.impl" />
                       </exclusions>
                       <local-last value="true" />
                </sub-deployment>
          </jboss-deployment-structure>
          

           

           

           

          So in your case may be you can try it something like following:

           

          <jboss-deployment-structure>
                <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
                <deployment>
                       <dependencies>
                           <module name="org.hibernate.search.orm" services="export" />
                       </dependencies>
                       <exclusions>
                           <module name="org.slf4j" />
                           <module name="org.slf4j.impl" />
                       </exclusions>
                </deployment>
                <sub-deployment name="logiq-web.war">
                       <dependencies>
                           <module name="org.hibernate.search.orm" services="export" />
                       </dependencies>
                       <exclusions>
                           <module name="org.slf4j" />
                           <module name="org.slf4j.impl" />
                       </exclusions>
                       <local-last value="true" />
                </sub-deployment>
                <sub-deployment name="logiq-ejb.jar">
                       <dependencies>
                           <module name="org.hibernate.search.orm" services="export" />
                       </dependencies>
                       <exclusions>
                           <module name="org.slf4j" />
                           <module name="org.slf4j.impl" />
                       </exclusions>
               </sub-deployment>
          </jboss-deployment-structure>
          
          1 of 1 people found this helpful
          • 2. Re: Wildfly 8.2.0 application logging with logback
            Thomas Becker Newbie

            Hey Jay Kumar,

             

            thx for your reply! I've tried something similar yesterday:

             

            <!-- Aktiviert Hibernate Search für die Module im EAR file -->

            <jboss-deployment-structure>

                <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

                <deployment>

                    <dependencies>

                        <module name="org.hibernate.search.orm" services="export" />

                    </dependencies>

                    <exclusions>

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

                        <module name="org.slf4j" />

                        <module name="org.slf4j.impl" />

                    </exclusions>

                </deployment>

                <sub-deployment name="logiq-web.war">

                    <dependencies>

                        <module name="org.hibernate.search.orm" services="export" />

                    </dependencies>

                    <local-last value="true" />

                    <exclusions>

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

                        <module name="org.slf4j" />

                        <module name="org.slf4j.impl" />

                    </exclusions>

                </sub-deployment>

                <sub-deployment name="logiq-ejb.jar">

                    <dependencies>

                        <module name="org.hibernate.search.orm" services="export" />

                    </dependencies>

                    <exclusions>

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

                        <module name="org.slf4j" />

                        <module name="org.slf4j.impl" />

                    </exclusions>

                </sub-deployment>

            </jboss-deployment-structure>

             

            With the effect that the application started and used my logback.xml. However I have now a combination of the logging pattern in jboss and my logback message:

             

            [0m [0m12:15:09,833 INFO  [stdout] (default task-64) 12:15:09.833 [default task-64] [username qeoFoKk2Du0H6WiSgxEX8l3i] DEBUG some.package.event.ExecutionMonitor - execution finished: Execution [z_kn4-801175321] - 5756ms, 570 event(s) taking 1584674µs

             

            What's the cause of this now and how can I avoid it?