2017-10-11 35 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中單擊,第二個在速度上,並且它們發生衝突 –