11 Replies Latest reply on Jul 16, 2013 5:14 AM by mkouba

    How to configure Weld-SE logger ?

    rpelisse

      Hi all,

       

      I've turned a CDI WebApp into a command line tool very easily using the weld-se container to do the bootstrap:

       

       

       



      WeldContainer weld = new Weld().initialize();


      MyService machineService = weld.instance().select(MyService.class).get();

       

       

      This is awesome and working fine, but Weld logs a LOT of usefull information :

       

      75 [main] INFO org.jboss.weld.Version - WELD-000900 SNAPSHOT

      845 [main] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.

      3467 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.bean.BeanDocumentFactory because of underlying class loading error

      3497 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.datatype.DatatypeAttribute because of underlying class loading error

      3500 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.datatype.DatatypeDocumentFactory because of underlying class loading error

      3501 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.datatype.DatatypeElement because of underlying class loading error

      3502 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.datatype.DatatypeElementFactory because of underlying class loading error

      3503 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.datatype.NamedTypeResolver because of underlying class loading error

      3504 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.datatype.SchemaParser because of underlying class loading error

      3507 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.DocumentFactory because of underlying class loading error

      3509 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.DocumentHelper because of underlying class loading error

      3523 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.dom.DOMDocumentFactory because of underlying class loading error

      3708 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.io.XPP3Reader because of underlying class loading error

      3709 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.io.XPPReader because of underlying class loading error

      3729 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.rule.Stylesheet because of underlying class loading error

      3775 [main] INFO org.jboss.weld.ClassLoading - WELD-000119 Not generating any bean definitions from org.dom4j.swing.XMLTableDefinition because of underlying class loading error

      ...

       

       

      I've googled around, but I failed to find how I could configure this logger... I've tried adding the logging.properties (java util logging), but does not appears to be picked up. I also added log4j as a dependency and added the log4j.xml, but same thing, even with an invalid XML file, Weld-SE seems to ignore this file aslo...

        • 1. Re: How to configure Weld-SE logger ?
          mkouba

          Hi Romain,

           

          Weld is using Simple Logging Facade for Java (http://www.slf4j.org/). Weld SE (Uber Jar) bundles Simple binding implementation which outputs all events to System.err and it's level is INFO by default. You can use system properties and "simplelogger.properties" file to configure the SimpleLogger  (see also SimpleLogger javadoc).

          1 of 1 people found this helpful
          • 2. Re: How to configure Weld-SE logger ?
            rpelisse

            Hi Matrin,

             

            Thanks for your input, it's quite useful as I had wrongly deduce from my googling that there was no way to configure slf4j (that being a facade, there was no configuration available). However, I'm still stuck in a strange fashion. I've added the simplelogger.properties file, and it's package at the root of my jar:

             

            $ unzip -t target/VmSetup-1.0-SNAPSHOT-jar-with-dependencies.jar | grep simplelogger

                testing: simplelogger.properties   OK

             

            $ cat target/classes/simplelogger.properties

            org.slf4j.simpleLogger.defaultLogLevel=ERROR

            org.slf4j.simpleLogger.log.org.jboss.weld.ClassLoading=ERROR

             

            I even tried to configure the defaultLogLevel, by adding a system property:

             



            Properties props = System.getProperties();


            props.put("org.slf4j.simpleLogger.defaultLogLevel", "ERROR");


            System.setProperties(props);

             



            WeldContainer weld = new Weld().initialize();

             

            Nevertheless, those settings are ignored and Weld-se keeps printing INFO message

            • 3. Re: How to configure Weld-SE logger ?
              mkouba

              I've just tested the org.slf4j.simpleLogger.defaultLogLevel system property (System.setProperties(), System.setProperty() and also JVM option -Dorg.slf4j.simpleLogger.defaultLogLevel=ERROR) and it works fine - no info messages printed out. Are you sure the container is initialized after the system property is set?

              • 4. Re: How to configure Weld-SE logger ?
                rpelisse

                Hi Martin,

                 

                It does not works for me - but I must have something wrong in my local settings (it should indeed work):

                 

                $ java -Dorg.slf4j.simpleLogger.defaultLogLevel=ERROR -cp target/VmSetup-1.0-SNAPSHOT-jar-with-dependencies.jar  org.reat.service.VmSetUp -s http://url -u bob -p pw -a create -f specs.txt

                25 [main] INFO org.jboss.weld.Version - WELD-000900 SNAPSHOT

                253 [main] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.

                ...

                 

                Maybe this is a JDK induced issue ? Mine is :

                 

                $ java -version

                java version "1.7.0_25"

                OpenJDK Runtime Environment (fedora-2.3.10.3.fc18-x86_64)

                OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

                • 5. Re: How to configure Weld-SE logger ?
                  mkouba

                  I have no idea but I tested this with Oracle JDK 1.7.0_09

                  • 6. Re: How to configure Weld-SE logger ?
                    rpelisse

                    Hi,

                     

                    Ok, I've pushed a simple project reproducing my issue on github: https://github.com/rpelisse/weld-se-log-issue

                     

                    $ git clone https://github.com/rpelisse/weld-se-log-issue weld-se-logging.git

                    $ cd weld-se-logging.git

                    $ mvn clean package exec:java

                    ...

                    [INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ WeldSeLogIssue ---

                    [INFO] Building jar: /home/rpelisse/Repositories/contrib/weld-log-issue.git/target/WeldSeLogIssue-1.0-SNAPSHOT.jar

                    [INFO]

                    [INFO] --- maven-assembly-plugin:2.4:single (assemble-all) @ WeldSeLogIssue ---

                    [INFO] Building jar: /home/rpelisse/Repositories/contrib/weld-log-issue.git/target/WeldSeLogIssue-1.0-SNAPSHOT-jar-with-dependencies.jar

                    [INFO]

                    [INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ WeldSeLogIssue >>>

                    [INFO]

                    [INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ WeldSeLogIssue <<<

                    [INFO]

                    [INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ WeldSeLogIssue ---

                    18 [org.redhat.service.WeldSeLogIssue.main()] INFO org.jboss.weld.Version - WELD-000900 1.1.10 (Final)

                    88 [org.redhat.service.WeldSeLogIssue.main()] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.

                    253 [org.redhat.service.WeldSeLogIssue.main()] WARN org.jboss.weld.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled

                    253 [org.redhat.service.WeldSeLogIssue.main()] WARN org.jboss.weld.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled

                    MyBeanImpl

                    [INFO] ------------------------------------------------------------------------

                    [INFO] BUILD SUCCESS

                    [INFO] ------------------------------------------------------------------------

                    [INFO] Total time: 4.468s

                    [INFO] Finished at: Tue Jul 16 10:14:44 CEST 2013

                    [INFO] Final Memory: 25M/238M

                    [INFO] ------------------------------------------------------------------------

                    $ head target/classes/simplelogger.properties

                    org.slf4j.simpleLogger.defaultLogLevel=ERROR

                    org.slf4j.simpleLogger.log.org.jboss.weld=ERROR

                     

                    If some of you can run it on their local environment and tell me if you also got the same issue (the WARN statement), that'll be great ! Thansks !

                    • 7. Re: How to configure Weld-SE logger ?
                      rpelisse

                      Hi Martin,

                       

                      On second though, I really don't think it could be tied to the JDK, but maybe simply to the Weld version (or dependencies) that I use, take a look at my sample project, and let me know if you see a difference with your own setup !

                       

                      Thanks !

                      • 8. Re: How to configure Weld-SE logger ?
                        luksa

                        I see WARNs with 1.1.10.Final, but not with 1.1.11.Final or later.

                        • 9. Re: How to configure Weld-SE logger ?
                          mkouba

                          Exactly... this issue might be related: https://issues.jboss.org/browse/WELD-1063

                          • 10. Re: How to configure Weld-SE logger ?
                            rpelisse

                            Ok, that was silly - I though that the 1.1.10 was the latest release ! I had not noticied the 1.1.11.Final. Indeed, this fix my issue...

                             

                            Thanks guys !

                            • 11. Re: How to configure Weld-SE logger ?
                              mkouba

                              Actually the latest 1.1.x latest release is 1.1.13.Final