我使用了速度-1.6.2.jar
我在服务器上创建 velocity.log 的问题是从 jboss / bin
开始的jboss / bin 拥有只读权限。
并在我的appilcation中调用velocity-1.6.2.jar时出现此错误:
Caused by: java.io.FileNotFoundException: velocity.log (Permission denied)
我想更改Velocity.Log文件的位置
这是我的速度属性中的位置线:
# ----------------------------------------------------------------------------
# default LogChute to use: default: AvalonLogChute, Log4JLogChute, CommonsLogLogChute, ServletLogChute, JdkLogChute
# ----------------------------------------------------------------------------
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
# ---------------------------------------------------------------------------
# This is the location of the Velocity Runtime log.
# ----------------------------------------------------------------------------
runtime.log = velocity.log
答案 0 :(得分:2)
Runtime log可以获得完整路径,只需直接登录到您的可摘文件夹/home/velocity.log
runtime.log = /home/velocity.log
错误,警告和信息性消息的日志文件的完整路径和名称。如果不是绝对的,该位置相对于当前目录'。
日志路径也可以通过编程方式设置如下:
import org.apache.velocity.app.VelocityEngine;
public class VelocityCustomEngine extends TemplateEngine {
private final VelocityEngine velocityEngine;
public VelocityCustomEngine() {
Properties properties = new Properties();
properties.setProperty("runtime.log", "/home/velocity.log");
this.velocityEngine = new VelocityEngine(properties);
}
}
答案 1 :(得分:0)
我知道有答案。如果您不想扩展原始的VelocityEngine。 您还可以新建一个VelocityEngine实例,仅在init()方法之前更改“ runtime.log”属性,而无需任何新类。
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty("runtime.log", "/home/velocity.log");
velocityEngine.setProperty(RuntimeConstants.ENCODING_DEFAULT, "UTF-8");
velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
velocityEngine.setProperty("classpath.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
velocityEngine.init();//init method will use the properties(include the log file location) actually.
return velocityEngine;