log filter that matches 'this' or 'that'
kdolan1 Jun 14, 2012 3:49 PMThe good news is I already have a solution. I'm curious if anyone knows why my other tries did not work or can provide some additional context.
I have a console-handler that has a filter such that only one specific log message (e.g., Deployed app) gets logged.
<console-handler name="STATUS" autoflush="true">
<level name="INFO"/>
<filter>
<match pattern="JBAS018559"/>
</filter>
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n"/>
</formatter>
<target name="System.out"/>
</console-handler>
I wanted to add another message (e.g., Composite operation was rolled back) to this such that now two specific log messages get logged. My first change was to make filter look like the one below (I found a post w/ an example like this except it was using <not>).
<filter>
<any>
<match pattern="JBAS014654"/>
<match pattern="JBAS018559"/>
</any>
</filter>
This did not work. Only one message will actually be logged on start-up (either apps deploy or they don't) so I only expected to see one or the other. However, JBoss re-writes standalone.xml and in doing so, ripped out the other <match> element. This would mean on re-start, JBoss would never print the other message if in fact that was the message encountered.
BTW - I also tried <all> as a group element. Same behavior.
The help text generated by the CLI talks about chaining multiple conditions but I could not find examples of this. The above was my attempt at this. Perhaps I was doing it wrong.
Ultimately, my solution took advantage of the pattern value being able to be a regular expression. I'm just wondering if there is a different way in case I ever find myself in need of something more complex that cannot be represented in a regular expression.
<filter>
<match pattern="JBAS014654|JBAS018559"/>
</filter>
Thoughts?
Kelly