速度初始化错误:AvalonLogChute 没有实现 LogChute [英] Velocity initialization error: AvalonLogChute does not implement LogChute

查看:33
本文介绍了速度初始化错误:AvalonLogChute 没有实现 LogChute的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试初始化 VelocityEngine 但在 .init() 调用时遇到异常:

I am trying to initialize VelocityEngine but getting exception on .init() call:

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

依赖树中没有第二个速度 jar.但是有 apache-click jar,据我所知,它包含它自己的 Velocity 实现或至少是其中的一部分.

There is no second velocity jar in dependency tree. But there is apache-click jar, which, from what I see, contains it's own Velocity implementation or at least part of it.

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

So it looks like classloader problem. I found temporary solution here: https://plus.google.com/116012605255269201011/posts/6tviyMPbqTU

但是我想知道有没有什么方法可以在不替换线程类加载器的情况下解决这个问题.

But I wonder if there is any way to solve this problem without substituting thread classloader.

推荐答案

Inside click jar you have velocity.properties org\apache\velocity\runtime\defaults\

Inside click jar you have velocity.properties org\apache\velocity\runtime\defaults\

您可以通过 3 种方式配置日志记录:

You can configure logging in 3 ways:

现有的 Log4j 记录器

从 1.3 版本开始,Velocity 将记录它的输出到现有的 Log4j Logger 设置中的其他位置应用.要使用此功能,您必须确保 Log4j jar在你的类路径中.(无论如何你都会这样做,因为你正在使用Log4j 在应用程序中使用 Velocity.)配置 Velocity 使用Log4JLogChute 类通过指定现有 Logger 的名称通过runtime.log.logsystem.log4j.logger"属性使用.笔记这种对 Logger 的支持是在 Velocity 的 1.5 版中.更远,在 1.5 版中,我们删除了现在非常古老且已弃用的原始版本Log4JLogSystem 类并替换为当前的 Log4JLogChute 类它使用 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.

自定义独立记录器

您可以创建自定义日志类 - 你只需要实现接口org.apache.velocity.runtime.log.LogChute 然后简单地设置带有类名的配置属性 runtime.log.logsystem.class,Velocity 将在初始化时创建该类的实例.你可以在指定任何其他属性时指定类名.见有关 Velocity 帮助程序类以及配置的信息键和值.请注意,旧org.apache.velocity.runtime.log.LogSystem 接口已经v1.5 已弃用,支持新的 LogChute 界面.这是由于无法对我们的日志代码进行重大升级LogSystem 接口支持.但别担心,如果你指定一个实现 LogSystem 接口的自定义类,它仍然会工作.但是,它会生成弃用警告.你应该尽快升级您的自定义记录器以实施 LogChute.

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.

集成日志

您可以集成 Velocity 的日志记录功能使用您的应用程序现有的日志系统,只需实现org.apache.velocity.runtime.log.LogChute 接口.然后,通过一个你的日志类的实例到 Velocity 通过初始化之前的 runtime.log.logsystem 配置键Velocity 引擎,Velocity 会将消息记录到您的应用程序的记录器.查看有关 Velocity 助手类的信息以及配置键和值.

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

这篇关于速度初始化错误:AvalonLogChute 没有实现 LogChute的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆