2011-10-17 11 views
6

私は(ちょうど-messages "によって引き起こされる" 掲示)このエラーが出る:ログインエラーが

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

で私のWindowsマシン上で

runtimeServices = RuntimeSingleton.getRuntimeServices(); 
node = runtimeServices.parse(reader, templateName); 

それがうまく動作しますが、Linuxシステム(10.04 Ubuntuの)で、それは動作しません:最初に私のコードは次のように見えました。このpostは、私が書き込み権限を与えなければならないディレクトリの手がかりを見つけられなかったので、あまり役に立たない。

私は、次のコードは、Linuxマシンでも動作していること、が分かった:

String logPath = request.getRealPath("/velocity.log"); 
RuntimeSingleton.setProperty(RuntimeConstants.RUNTIME_LOG, logPath); 
runtimeServices = RuntimeSingleton.getRuntimeServices(); 
node = runtimeServices.parse(reader, templateName); 

私は私の本当の文脈上の書き込み権限を持っている場合、私は、必ずすることができませんでしたので、それは、非常に素晴らしい解決策ではありませんパス。最高ののは、Velocityのロギングをオフにすることだけです。

どのような異なるロギング設定を設定する必要がありますか? NullLogChuteは機能していませんか、それとも不適切なのですか?

ありがとうございます!

答えて

0

こんにちは、この問題は書き込み権限で保護されています。あなたが持っているあなたのスタックトレースで Infactは:

java.io.FileNotFoundException: velocity.log (Permission denied) 

だから、それは良いものだが、速度ログが書き込まれる場所を決定します。 あなたは良い言葉を言っています。プロダクションでは特定のパスに書き込めるかどうかはわかりません。 したがって、sysadminが必要に応じて変更できるプロパティファイルに、そのパスを入れる方がよいでしょう。

これを確認して、別の投稿に回答してください。

リンクhere

関連する問題