5 Replies Latest reply on Oct 19, 2015 4:11 AM by doc_fire

    JBoss EAP 6.4 logging filter-spec

    doc_fire

      I'm trying to use the "filter-spec ..." definition independently for different handlers.

      The problem is that there is some kind of inheritance that I really cannot figure out: When using the "filter-spec ..." within the console-handler the filter is also applied within the size-rotating-file-handler but not the other way round.

      I want to use the filter within the console-handler only for the console-handler and the filter within the size-rotating-file-handler only for the size-rotating-file-hanlder.

      Current configuration looks similar to this (I've also tried it without the "filter-spec value="accept"" within the root-logger)

       

       

      <subsystem xmlns="urn:jboss:domain:logging:1.5">
              <console-handler name="CONSOLE">
                  <level name="DEBUG"/>
                  <filter-spec value="all(substituteAll(&quot;\n&quot;,&quot;/n&quot;), substituteAll(&quot;\r&quot;,&quot;/r&quot;), substituteAll(&quot;\t&quot;,&quot;/t&quot;))"/>
                  <formatter>
                      <named-formatter name="DEFAULT_LOG_PATTERN"/>
                  </formatter>
              </console-handler>
              <size-rotating-file-handler name="SFILE">
                  <level name="INFO"/>
                  <filter-spec value="all(substituteAll(&quot;a&quot;,&quot;AA&quot;), substituteAll(&quot;e&quot;,&quot;EE&quot;)), levels(INFO)"/>
                  <formatter>
                      <named-formatter name="DEFAULT_LOG_PATTERN"/>
                  </formatter>
                  <file relative-to="jboss.server.log.dir" path="sizerotated.log"/>
                  <rotate-size value="1M"/>
                  <max-backup-index value="15"/>
                  <append value="true"/>
              </size-rotating-file-handler>
              <logger category="org.hibernate.SQL">
                  <level name="DEBUG"/>
                  <filter-spec value="accept"/>
              </logger>
              ...
              <root-logger>
                  <level name="INFO"/>
                  <filter-spec value="accept"/>
                  <handlers>
                      <handler name="CONSOLE"/>
                      <handler name="SFILE"/>
                  </handlers>
              </root-logger>
              <formatter name="DEFAULT_LOG_PATTERN">
                  <pattern-formatter pattern="&quot;%d{yyyy-MM-dd HH:mm:ss.......;%E&quot;;%n"/>
              </formatter>
          </subsystem>
      
      

       

      I found out that if the order of the handlers within the "root-logger" is changed to:

       

       <handler name="SFILE"/>
       <handler name="CONSOLE"/>
      

       

      then the inheritance is the other way round.

        • 1. Re: JBoss EAP 6.4 logging filter-spec
          jamezp

          What makes you think they're inherited? Filters on handlers are not shared to other handlers at all.

           

          Also I don't see any reason to have the filter on the root-logger or the the org.hibernate.SQL handler.

           

          --

          James R. Perkins

          • 2. Re: JBoss EAP 6.4 logging filter-spec
            doc_fire

            Because this filter defined within CONSOLE:

             

            <filter-spec value="all(substituteAll(&quot;\n&quot;,&quot;/n&quot;), substituteAll(&quot;\r&quot;,&quot;/r&quot;), substituteAll(&quot;\t&quot;,&quot;/t&quot;))"/>


            also gets applied for the SFILE, which is not what i expected. It should only apply for the CONSOLE handler.


            And if i change the order of handlers within the root-logger then the SFILE filter-spec is applied to the CONSOLE handler.


            They are shared somehow  -  thats exactly my question.


            "Also I don't see any reason to have the filter on the root-logger or the the org.hibernate.SQL handler." - this was only a test...@James Perkins

            • 3. Re: JBoss EAP 6.4 logging filter-spec
              jamezp

              Which JDK are you using by chance? I seem to see this issue with Java 8 but not with Java 7 for some reason.

               

              --

              James R. Perkins

              • 4. Re: JBoss EAP 6.4 logging filter-spec
                jamezp

                It looks like handlers are not inherited, but when one handler runs and changes the LogRecord the second handler sees those changes as well. The behavior is essentially happening because the LogRecord is shared. You can file a JIRA if you feel it's the wrong behavior. It would likely cause some performance degradation though.

                 

                --

                James R. Perkins

                • 5. Re: JBoss EAP 6.4 logging filter-spec
                  doc_fire

                  Yeah. I m using Java 8. For the moment i wont fill a JIRA ticket because I dont need it absolutely but I think it is wrong behavior. Thank you for the moment!