Tuesday, 10 September 2013

Recording throwables with SLF4J

Recording throwables with SLF4J

What is the proper way to catch an exception such as "throw
UnsupportedOperationException" and have it transcribed in SLF4J? I already
have the JUL to SLF4j api set up correctly; however it doesn't seem to log
exceptions that are thrown instead of logged; I had assumed that the
bridge would take care of this. Is there something that i am missing in
the configuration?
In the application I use something along the lines of
java.util.logging.Logger.getLogger("global").setLevel(java.util.logging.Level.FINEST);
java.util.logging.LogManager.getLogManager().reset();
org.slf4j.bridge.SLF4JBridgeHandler.install();
and in the configuration file I have
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
having library specific or any other errors thrown in a library such as
throw SqlException is not logged in the file and so i am assuming is not
recognized by logback.

No comments:

Post a Comment