Always log, regardless of level, but not as ERROR

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 -- View this message in context: http://www.nabble.com/Always-log%2C-regardless-of-level%2C-but-not-as-ERROR-... Sent from the Logback User mailing list archive at Nabble.com.

use a dedicated logger and appender for this message (which can not be tweeked by jmx)? On Tue, 2009-09-15 at 06:31 -0700, 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

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

Sweet. Worked like a charm. Thanks. Ceki Gulcu wrote:
You can mark a logging statement as "ALWAYS" and have a turbo filter act upon it.
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 Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
-- View this message in context: http://www.nabble.com/Always-log%2C-regardless-of-level%2C-but-not-as-ERROR-... Sent from the Logback User mailing list archive at Nabble.com.
participants (3)
-
Ceki Gulcu
-
dirk ooms
-
laboo