![](/img/trans.png)
[英]Velocity 2.0: NoClassDefFoundError: org/apache/velocity/runtime/log/CommonsLogLogChute
[英]Apache Velocity 2.0 - log binding issue?
我正在使用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的警告,请参阅说明 :
当类路径上有多个绑定时,请选择一个且仅选择一个您要使用的绑定,然后删除其他绑定。 例如,如果您在类路径上同时拥有slf4j-simple-1.8.0-alpha2.jar和slf4j-nop-1.8.0-alpha2.jar,并且希望使用nop(无操作)绑定,请删除类路径中的slf4j-simple-1.8.0-alpha2.jar。
如果需要在类路径中保留slf4j-simple,则根本无法添加slf4j-nop jar。
在类路径中根本不能有两个slf4j绑定jar。
您需要做的是通过配置SimpleLogger来关闭Velocity日志。
例如,您可以定义以下系统属性:
org.slf4j.simpleLogger.log.org.apache.velocity = off
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.