如何在 NVelocity 中启用日志记录?
知道如何按照标题所说的去做吗?我唯一发现的是在原始 Velocity 站点上,我认为
ve.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
"org.apache.velocity.runtime.log.Log4JLogChute" );
ve.setProperty("runtime.log.logsystem.log4j.logger",
LOGGER_NAME);
在 .NET 上效果不佳。我正在使用 log4net,这应该会很容易,但是 NVelocity 的文档确实很混乱。
Any idea how to do what the title says? Only thing I found was on the original Velocity site, and I don't think
ve.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
"org.apache.velocity.runtime.log.Log4JLogChute" );
ve.setProperty("runtime.log.logsystem.log4j.logger",
LOGGER_NAME);
will work wonderfully well on .NET. I am using log4net, which should make it quite easy, but the documentation on NVelocity is really a mess.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实现
NVelocity.Runtime.Log.ILogSystem
(您可以编写一个桥接到 log4net 的简单实现)并在属性RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS
中设置此 impl 类型我如何获取此信息:
Implement
NVelocity.Runtime.Log.ILogSystem
(you could write a simple implementation that bridges to log4net) and set this impl type in the propertyRuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS
How I got this information:
更新:
目前,NVelocity 不支持日志记录。 RuntimeInstance类中的initializeLogger()和Log()方法被注释掉。
如果您需要记录,请取消注释这两个方法,添加一个
private ILogSystem logSystem;
属性这是我们的即时实现:
然后,我们为 log4net 实现了 ILogSystem
然后,在创建引擎时:
Update:
Currently, NVelocity does not support logging. The initializeLogger() and Log() methods in RuntimeInstance Class are commented out.
If you need to log, uncomment the two methods, add a
private ILogSystem logSystem;
propertyHere's our on-the-fly implementation:
Then, we implemented ILogSystem for log4net
Then, when creating the engine: