【发布时间】:2018-03-13 13:36:46
【问题描述】:
我正在使用 Apache Velocity 2.0。我正在尝试设置 slf4j 绑定。如 Apache Velocity 文档中所述,我设置了所需的依赖项。 这样完成并说我现在期望使用 NOPLogger 因为没有任何日志使用情况。我的代码如下:
// Get template engine
VelocityEngine templateEngine = new VelocityEngine();
// Init template engine
templateEngine.addProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, new NOPLoggerFactory().getLogger(""));
templateEngine.init();
我的问题是执行“new VelocityEngine();”我在调试器控制台中得到以下跟踪:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://23.fwk288994035:3/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://23.fwk288994035:8/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
???
我看了一下 Apache 源代码:
public class VelocityEngine implements RuntimeConstants
{
private RuntimeInstance ri = new RuntimeInstance();
....
}
public class RuntimeInstance implements RuntimeConstants, RuntimeServices
{
/**
* The Runtime logger. The default instance is the "org.apache.velocity" logger.
*/
private Logger log = LoggerFactory.getLogger(DEFAULT_RUNTIME_LOG_NAME);
....
}
对我来说听起来,所以记录器是获取优先集成商获取指定它的能力... 在我的环境中。我可能已经运行了一些其他记录器(我依赖的第三方贡献),所以我得到了如此无聊的跟踪。
我的分析可以吗?有什么技巧可以分享一下解决问题?
【问题讨论】:
-
你的 slf4j jar 是什么?
-
我已经添加了 sl4j-api 和 sl4j-simple jars 作为 Apache 的velocity 的插件。由于期望到那时设置 NOPLogger 我已经尝试删除 sl4j-simple 一个但当时速度失败了....思考问题总是相同的速度是需要记录器事先提供定义它的能力...所以记录器查找器正在运行...