6
當instatiating速度我得到這個錯誤(貼只是 「引發的」 -messages):登錄錯誤在Linux系統上
java.lang.RuntimeException: Velocity could not be initialized!
Caused by: org.apache.velocity.exception.VelocityException: Error initializing log: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
Caused by: org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
Caused by: java.lang.RuntimeException: Error configuring Log4JLogChute :
Caused by: java.io.FileNotFoundException: velocity.log (Permission denied)
這是我的代碼片段:
VelocityEngine ve = new VelocityEngine();
ve.evaluate(context, writer, "org.apache.velocity.runtime.log.NullLogChute", this.templateString);
在首先我的代碼是這樣的:
runtimeServices = RuntimeSingleton.getRuntimeServices();
node = runtimeServices.parse(reader, templateName);
在我的Windows機器能正常工作,但在Linux系統(Ubuntu的10.04),這是行不通的。這post並沒有多大幫助,因爲我還沒有找到任何線索哪些目錄我必須給寫權限。
我發現,下面的代碼是在Linux機器也工作:
String logPath = request.getRealPath("/velocity.log");
RuntimeSingleton.setProperty(RuntimeConstants.RUNTIME_LOG, logPath);
runtimeServices = RuntimeSingleton.getRuntimeServices();
node = runtimeServices.parse(reader, templateName);
這不是一個很好的解決方案,因爲我從來沒有肯定,如果我有我的真實背景下的寫入權限路徑。最好的情況是,關閉Velocity的日誌記錄。
我必須設置什麼不同的日誌記錄配置? NullLogChute
只是不工作,或者我不適合使用它嗎?
在此先感謝!