本文介绍了如何找到slf4j绑定到哪个库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用slf4j登录我的应用程序。
我得到了slf4j的目的。我想知道如何找出当前绑定到哪个日志库slf4j。我在引用的库中有log4j。我假设slf4j已经绑定到log4j。

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?

推荐答案

只需执行SLF4J发现的绑定:

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());

这打印:

ch.qos.logback.classic.LoggerContext[default]
ch.qos.logback.classic.selector.DefaultContextSelector

这篇关于如何找到slf4j绑定到哪个库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 03:48