2017-10-11 145 views
0

我想初始化VelocityEngine.init()电话获取例外:速度初始化错误:AvalonLogChute没有实现LogChute

org.apache.velocity.exception.VelocityException: The specified logger 
class org.apache.velocity.runtime.log.AvalonLogChute does not 
implement the org.apache.velocity.runtime.log.LogChute interface. 

我的代码如下所示:

VelocityEngine velocityEngine = new VelocityEngine(); 
velocityEngine.setProperty(....) //I do not change logging properties 
... 
velocityEngine.init(); 

没有第二速度罐子在依赖关系树中。但是有一个apache-click jar,根据我所看到的,它包含了它自己的Velocity实现或者至少是它的一部分。

所以它看起来像类加载器的问题。 我在这里找到了临时解决方案:https://plus.google.com/116012605255269201011/posts/6tviyMPbqTU

但我想知道是否有任何方法可以解决这个问题,而不用替换线程类加载器。

+0

@ user7294900因为我已经写了没有其他速度版本在classpath中。然而,有一个apache点击,其中包含一些与速度jar相同名称和包的速度类,但它不是一个单独的库,它在apache内点击jar。不幸的是,我无法排除Apache的点击罐子。 –

回答

0

内单击罐子你有velocity.properties org\apache\velocity\runtime\defaults\

您可以configure logging有3种方式:

Existing Log4j Logger

Starting with version 1.3, Velocity will log its output to an existing Log4j Logger setup elsewhere in the application. To use this feature you must Make sure that the Log4j jar is in your classpath. (You would do this anyway since you are using Log4j in the application using Velocity.) Configure Velocity to use the Log4JLogChute class by specifying the name of the existing Logger to use via the 'runtime.log.logsystem.log4j.logger' property. Note that this support for Logger is in version 1.5 of Velocity. Further, in version 1.5 we removed the now-ancient and very deprecated original Log4JLogSystem class and replaced with the current Log4JLogChute class which uses the Logger class. We apologize for the confusion, but we needed to move on.

Custom Standalone Logger

You can create a custom logging class - you just need to implement the interface org.apache.velocity.runtime.log.LogChute and then simply set the configuration property runtime.log.logsystem.class with the classname, and Velocity will create an instance of that class at init time. You may specify the classname as you specify any other properties. See the information on the Velocity helper class as well as the configuration keys and values. Please note that the old org.apache.velocity.runtime.log.LogSystem interface has been deprecated for v1.5 in favor of the new LogChute interface. This is due to significant upgrades to our logging code that could not be supported by the LogSystem interface. But don't worry, if you specify a custom class that implements the LogSystem interface, it will still work. However, it will generate deprecation warnings. You should upgrade your custom logger to implement LogChute as soon as possible.

Integrated Logging

You can integrate Velocity's logging capabilities with your applications existing logging system, simply by implementing the org.apache.velocity.runtime.log.LogChute interface. Then, pass an instance of your logging class to Velocity via the runtime.log.logsystem configuration key before initializing the Velocity engine, and Velocity will log messages to your application's logger. See the information on the Velocity helper class as well as the configuration keys and values.

当前运行日志:

runtime.log.logsystem.class = org.apache.velocity.runtime.log.AvalonLogChute,org.apache.velocity.runtime.log.Log4JLogChute,org.apache.velocity.runtime.log.CommonsLogLogChute,org.apache.velocity.runtime.log.ServletLogChute,org.apache.velocity.runtime.log.JdkLogChute 
+0

我不知道这应该如何帮助?问题是有两个LogChute接口在apache中单击,第二个在速度上,并且它们发生冲突 –