更改 Velocity.Log 文件的位置
看起来很简单。文档位于 http://velocity.apache.org/engine/devel/developer-guide.html#配置_日志记录 说要设置runtime.log属性。这是我所有财产的所得。
velocityEngine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatesPath);
velocityEngine.setProperty("runtime.log", "/path/to/my/file/velocity.log");
velocityEngine.setProperty("resource.loader", "string");
velocityEngine.setProperty("string.resource.loader.class", "org.apache.velocity.runtime.resource.loader.StringResourceLoader");
velocityEngine.setProperty("string.resource.loader.repository.class", "org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl");
没有找到任何我告诉它放置的日志文件,而是找到放置在旧(初始化文件夹)位置的新错误。有什么想法吗? :D
Seems pretty straight forward. Documentation at http://velocity.apache.org/engine/devel/developer-guide.html#Configuring_Logging
says to set the runtime.log property. Here's what I got for all my properties.
velocityEngine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatesPath);
velocityEngine.setProperty("runtime.log", "/path/to/my/file/velocity.log");
velocityEngine.setProperty("resource.loader", "string");
velocityEngine.setProperty("string.resource.loader.class", "org.apache.velocity.runtime.resource.loader.StringResourceLoader");
velocityEngine.setProperty("string.resource.loader.repository.class", "org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl");
Not finding any log file where I told it to place it and instead finding the new errors placed into old (folder of initialization) location. Any ideas? :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在运行时设置一些选项时遇到了类似的问题。我通过自定义 VelocityBuilder 和外部 Velocity.properties 文件解决了这些问题,您可以在其中放置所有运行时属性。
这是代码:
请参阅这一行:
所以我在 /WEB-INF 中有一个velocity.properties文件,我在其中放置了一些配置:
最后在您的application.xml中:
通过这种方式,您可以为不同的文件设置不同的文件日志当您在生产中进行战争时,sysadm 可以根据生产服务器的 env 配置来更改属性。
i had similar problem when setting at runtime some options. I figured out those problem whit a custom VelocityBuilder and an external velocity.properties file where you can put all the runtime properties.
Here is the code:
See this line:
So i have a velocity.properties file in /WEB-INF where i put some configuration:
In the end in your application.xml :
In this way you can have for example different file log for different application and when you give the war in production, the sysadm can change the properties due to env configuration of the production server.