1 Reply Latest reply on Mar 30, 2017 11:42 AM by James Perkins

    Logging filter-spec substituteAll details

    Jeff Greif Newbie

      Logging from my deployed EAR in Wildfly 8.1 uses a custom substitution filter implemented with respect to our java.util.Logging-based implementation.

       

      I would also like to use a similar filter in a certain logging handler created before the EAR deployment via standalone.xml.  I intended to add a <filter-spec> to the relevant logging handler, but this raised some questions.

       

      1.  The filter spec is supposed to be of 'substituteAll' type.  Presumably the pattern may be a regex, but other aspects don't appear to be documented.

         a.  What is the regular expression language?  Java or something else?

         b.  Are all the constructs of that language usable, for example, capture groups that can be referenced in the replacement?

       

      2.  The details of quoting/escaping characters in the pattern and replacement in the filter-spec@value attribute, involving both XML restrictions and quoting for the regex language are tricky.  Is there another way of adding the filter spec which will do at least the XML part automatically?

       

      3.  Is it possible to specify a custom filter class that does the substitution, and, if so, how would it be specified, and where would the jar containing this class have to be placed in order to have it accessible when the logging configuration in standalone.xml is set up?

        • 1. Re: Logging filter-spec substituteAll details
          James Perkins Master

          Just in case you haven't seen it there is some documentation here Logging Configuration - WildFly 10 - Project Documentation Editor.

           

          1.  The filter spec is supposed to be of 'substituteAll' type.  Presumably the pattern may be a regex, but other aspects don't appear to be documented.

             a.  What is the regular expression language?  Java or something else?

             b.  Are all the constructs of that language usable, for example, capture groups that can be referenced in the replacement?

          The regular expression language is Java. You can use anything supported by java.util.regex.Pattern. If you want to see the details on how it's implemented it is on GitHub.

           

          2.  The details of quoting/escaping characters in the pattern and replacement in the filter-spec@value attribute, involving both XML restrictions and quoting for the regex language are tricky.  Is there another way of adding the filter spec which will do at least the XML part automatically?

          It's always best to use the web console, CLI or other management interface. Editing the XML is possible, but generally discouraged. For something like a log filter with the web console or CLI you can make changes without requiring the server to be stopped or restarted. In the case of logging changes it's better to use a management interface because during boot the logging configuration doesn't come from the XML configuration file. Using management operations ensures that the boot logging will be identical to how the logging subsystem is configured.

           

          As an example this CLI command would change all the WFLY prefixes on messages to WILDFLY on the console:

          /subsystem=logging/console-handler=CONSOLE:write-attribute(name=filter-spec, value="substituteAll(\"WFLY\", \"WILDFLY\")")
          

           

          3.  Is it possible to specify a custom filter class that does the substitution, and, if so, how would it be specified, and where would the jar containing this class have to be placed in order to have it accessible when the logging configuration in standalone.xml is set up?

          Currently it's not possible. However you could file a feature request at http://issues.jboss.org/browse/WFCORE.

           

          --

          James R. Perkins

          1 of 1 people found this helpful