7 Replies Latest reply on Jan 22, 2010 2:17 PM by David Lloyd

    AS6 Logging

    Stan Silvert Master

      Has anyone (David L?) written some doco on Logging for AS6?

       

      I want to suppress a bogus error message from applications that use legacy Facelets.  https://jira.jboss.org/jira/browse/JBAS-7600

       

      However, when I add a filter to a java.util.logging.Logger, the filter never gets called.

       

      Stan

        • 1. Re: AS6 Logging
          David Lloyd Master

          stan.silvert@jboss.com wrote:

           

          Has anyone (David L?) written some doco on Logging for AS6?

           

          I want to suppress a bogus error message from applications that use legacy Facelets.  https://jira.jboss.org/jira/browse/JBAS-7600

           

          However, when I add a filter to a java.util.logging.Logger, the filter never gets called.

           

          Stan

           

          Hmm.  I was very sure that I did have a document for this, but maybe I only dreamed it.

           

          You'll want something like this:

             ...
             <logger category="facelets.compiler">
                <filter>
                   <not>
                      <match pattern="^Error Loading Library:"/>
                   </not>
                </filter>
             </logger>
          

           

          I'd give that a go and see if it eliminates that message...

          • 2. Re: AS6 Logging
            Stan Silvert Master

            Is there any way to attach something like a java.util.logging.Filter written in java?  I'd like to do something a little more specific.

             

               public static class LegacyFaceletsLogFilter implements Filter
                {
                    public boolean isLoggable(LogRecord record)
                    {            
                        return !(record.getLevel().equals(Level.SEVERE) &&
                                 record.getThrown().getClass().equals(IOException.class) &&
                                 record.getMessage().contains("jsf-libs/jsf-impl.jar"));
                    }
                }
            

             

            Stan

            • 3. Re: AS6 Logging
              David Lloyd Master

              Yes, it's possible, but it can be a bit more dodgy.  The logging system only keeps weak references to loggers to avoid memory leaks.  So if you grab a logger and attach a filter to it, and then let it go before the "permanent" logger comes around, your logger might get GCd (and your filter lost) before the new logger comes around.  As long as you take care to hold on to your logger, you should be OK.

               

              And yes, you can use the JUL API to do this (that's what the underlying log manager is using anyway, so it's really the most efficient way).

               

              Another potential surprise is if the same logger category is explicitly configured in jboss-logging.xml, with (for example) a different filter definition, yours might get overwritten.  Or, the container's filter might; hard to say, really.  So I'd always recommend that such things go into the configuration rather than in code.  For a temporary fix it might be OK though.

              • 4. Re: AS6 Logging
                Stan Silvert Master

                david.lloyd@jboss.com wrote:

                 


                   ...
                   <logger category="facelets.compiler">
                      <filter>
                         <not>
                            <match pattern="^Error Loading Library:"/>
                         </not>
                      </filter>
                   </logger>

                 

                I'd give that a go and see if it eliminates that message...

                 

                So I tried something like about in jboss-logging.xml:


                <logger category="facelets.compiler">
                      <level name="INFO"/>
                      <filter>
                         <not>
                            <match pattern="jsf-libs/jsf-impl.jar"/>
                         </not>
                      </filter>
                   </logger>

                 

                I got:

                 

                12:59:53,791 ERROR [AbstractKernelController] Error installing to Real: name=vfs
                file:/C:/projects/astrunk/build/output/jboss-6.0.0-SNAPSHOT/server/default/deplo
                y/jboss-logging.xml state=PreReal mode=Manual requiredState=Real: org.jboss.depl
                oyers.spi.DeploymentException: Error deploying: vfsfile:/C:/projects/astrunk/bui
                ld/output/jboss-6.0.0-SNAPSHOT/server/default/deploy/jboss-logging.xml
                        at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentExcept
                ion(DeploymentException.java:49)
                        at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployerWithInpu
                t.deploy(AbstractRealDeployerWithInput.java:142)
                        at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployerWithInpu
                t.internalDeploy(AbstractRealDeployerWithInput.java:102)
                        at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(
                AbstractRealDeployer.java:55)
                        at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(Deployer
                Wrapper.java:179)
                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(Deployer
                sImpl.java:1660)
                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFi
                rst(DeployersImpl.java:1378)
                        at org.jboss.deployers.plugins.deployers.DeployersImpl.install(Deployers
                Impl.java:1319)
                        at org.jboss.dependency.plugins.AbstractControllerContext.install(Abstra
                ctControllerContext.java:378)
                        at org.jboss.dependency.plugins.AbstractController.install(AbstractContr
                oller.java:1856)
                        at org.jboss.dependency.plugins.AbstractController.incrementState(Abstra
                ctController.java:999)
                        at org.jboss.dependency.plugins.AbstractController.executeOrIncrementSta
                teDirectly(AbstractController.java:1217)
                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(Abstr
                actController.java:1141)
                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(Abstr
                actController.java:1048)
                        at org.jboss.dependency.plugins.AbstractController.change(AbstractContro
                ller.java:887)
                        at org.jboss.dependency.plugins.AbstractController.change(AbstractContro
                ller.java:602)
                        at org.jboss.deployers.plugins.deployers.DeployersImpl.process(Deployers
                Impl.java:898)
                        at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeploye
                rImpl.java:677)
                        at org.jboss.system.server.profileservice.repository.MainDeployerAdapter
                .process(MainDeployerAdapter.java:117)
                        at org.jboss.system.server.profileservice.repository.ProfileDeployAction
                .install(ProfileDeployAction.java:70)
                        at org.jboss.system.server.profileservice.repository.AbstractProfileActi
                on.install(AbstractProfileAction.java:53)
                        at org.jboss.system.server.profileservice.repository.AbstractProfileServ
                ice.install(AbstractProfileService.java:403)
                        at org.jboss.dependency.plugins.AbstractControllerContext.install(Abstra
                ctControllerContext.java:378)
                        at org.jboss.dependency.plugins.AbstractController.install(AbstractContr
                oller.java:1856)
                        at org.jboss.dependency.plugins.AbstractController.incrementState(Abstra
                ctController.java:999)
                        at org.jboss.dependency.plugins.AbstractController.executeOrIncrementSta
                teDirectly(AbstractController.java:1217)
                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(Abstr
                actController.java:1141)
                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(Abstr
                actController.java:1048)
                        at org.jboss.dependency.plugins.AbstractController.install(AbstractContr
                oller.java:842)
                        at org.jboss.dependency.plugins.AbstractController.install(AbstractContr
                oller.java:589)
                        at org.jboss.system.server.profileservice.repository.AbstractProfileServ
                ice.registerProfile(AbstractProfileService.java:308)
                        at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(
                ProfileServiceBootstrap.java:259)
                        at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(
                ProfileServiceBootstrap.java:100)
                        at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(A
                bstractServer.java:860)
                        at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.r
                un(AbstractServer.java:441)
                        at java.lang.Thread.run(Thread.java:619)
                Caused by: java.lang.IllegalStateException
                        at org.jboss.logging.metadata.LoggingMetaDataHelper.getFilterValue(Loggi
                ngMetaDataHelper.java:424)
                        at org.jboss.logging.metadata.LoggingMetaDataHelper.getFilterValue(Loggi
                ngMetaDataHelper.java:378)
                        at org.jboss.logging.metadata.LoggingMetaDataHelper.getValue(LoggingMeta
                DataHelper.java:348)
                        at org.jboss.logging.metadata.LoggingMetaDataHelper.createLoggerBeanMeta
                Data(LoggingMetaDataHelper.java:150)
                        at org.jboss.logging.metadata.LoggingMetaDataHelper.createBeanMetaData(L
                oggingMetaDataHelper.java:97)
                        at org.jboss.logging.metadata.LoggingMetaData.getBeans(LoggingMetaData.j
                ava:118)
                        at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryDeployer$B
                eanMetaDataFactoryDeployerVisitor.getComponents(BeanMetaDataFactoryDeployer.java
                :61)
                        at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryDeployer$B
                eanMetaDataFactoryDeployerVisitor.getComponents(BeanMetaDataFactoryDeployer.java
                :45)
                        at org.jboss.deployers.spi.deployer.helpers.AbstractDeploymentVisitor.de
                ploy(AbstractDeploymentVisitor.java:65)
                        at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployerWithInpu
                t.deploy(AbstractRealDeployerWithInput.java:125)
                        ... 34 more

                • 5. Re: AS6 Logging
                  David Lloyd Master

                  Hm, OK that's a bug. :-)  Though I don't quite see how it's possible.  Could you open a JBLOGGING JIRA issue for it?

                  • 6. Re: AS6 Logging
                    Stan Silvert Master

                    david.lloyd@jboss.com wrote:

                     

                    Hm, OK that's a bug. :-)  Though I don't quite see how it's possible.  Could you open a JBLOGGING JIRA issue for it?

                    Done.  https://jira.jboss.org/jira/browse/JBLOGGING-33

                    • 7. Re: AS6 Logging
                      David Lloyd Master
                      Fixed in trunk.  I even tested your exact filter to make sure. :-)