0 Replies Latest reply on Sep 3, 2011 10:13 PM by jingyi_wang

    How to programmtically attach a filter to a logger in JBoss AS 6.1.0?

    jingyi_wang

      I have a need to create a custom Filter (implementing java.util.logging.Filter) and programmatically add it to a given logger. I don't see isLoggable() in the Filter class get invoked. Is this something possible to do?

       

      Because I couldn't get my custom filter to work, I tried programmatically adding a JBoss-implemented filter, org.jboss.logmanager.filters.DenyAllFilter, to a logger. This didn't have any effect either. The isLoggable() method didn't seem to get called either.

       

      However, when I added this configuration in jboss-logging.xml:

      <logger category="mytest">

            <level name="INFO"/>

            <filter>

               <deny/>

            </filter>

         </logger>

      it worked just fine.

       

      So, my questions are: 1. is it possible to programmatically add a filter? 2. is it possible to use a custom filter?