Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find which library slf4j has bound itself to?

I am using slf4j for logging in my application. I get the purpose of slf4j. I would like to know how to find out which logging-library slf4j is currently binding to. I have log4j in my referenced libraries. I am assuming that slf4j has bound itself to log4j.

What I would like to know is, is there any way to explicitly confirm this binding?

like image 820
psykeron Avatar asked May 08 '12 19:05

psykeron


1 Answers

Just do what SLF4J does to discover the binding:

final StaticLoggerBinder binder = StaticLoggerBinder.getSingleton(); 

Now you can try to find out what is the actual implementation logback in my case:

System.out.println(binder.getLoggerFactory()); System.out.println(binder.getLoggerFactoryClassStr()); 

This prints:

ch.qos.logback.classic.LoggerContext[default] ch.qos.logback.classic.selector.DefaultContextSelector 
like image 148
Tomasz Nurkiewicz Avatar answered Oct 04 '22 00:10

Tomasz Nurkiewicz