Hello,
You can mark a logging statement as "ALWAYS" and have a turbo filter act upon
it.
Here is how you would mark a logging statement with the ALWAYS marker:
Marker ALWAYS = MarkerFactory.getMarker("ALWAYS");
logger.info(ALWAYS, "your message goes here");
You can than add a MarkerFilter to your logback.xml config file. This turbo
filter would look for the ALWAYS marker and matching occurrences would be
automatically logged (i.e. accepted) regardless of logging levels.
<configuration>
...
<turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
<Marker>ALWAYS</Marker>
<OnMatch>ACCEPT</OnMatch>
</turboFilter>
</configuration>
For more details on TurboFilters please see
http://logback.qos.ch/manual/filters.html#TurboFilter
HTH,
laboo wrote:
I'm looking for a way to always log a message regardless of the current level
of logger.
My application allows the user to change the level via JMX and I always want
to log a message that says, "The level was changed from X to Y".
I *could* accomplish this by specifying the highest level, ERROR, but it's
not an error, and I don't want it to show up as one.
In log4j, I was able to accomplish this by using the log() method with level
OFF (strangely enough). I tried doing something similar with logback's level
ALL, but it's not accepted as valid level to the log() method.
Is there a different/better way to accomplish this?
Thanks,
Laboo
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
_______________________________________________
Logback-user mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-user