开发者

Logging in Java Web Start using log4j

I am migrating my application to Java Web Start. I have a situation that my application logs the message using log4j and configuration file create the logs in the installation directory.

I am not sure how to create and store 开发者_如何学运维the logs while using Java Web Start. Could any one tell me how to specify the file location for log4j?


You can pass the option to the JVM when it starts. On windows, this would look like:

-Dlog4j.configuration=file:/C:/MyApp/bin/log4j.properties


We can add following entry in the log4j.property file

log4j.appender.F.File=${user.home}/quest.log 


While using log4j to log in your JWS application, your jnlp should contain reference to log4j library like this

<resources>
    <jar href="log4j-1.2.16.jar"/>
</resources> 

The log4j jar file should be in the same directory as of your JWS application jar file.

Where to Log : Most preferred location to log is inside user home as the user has all rights there to create and modify files. log4j.appender.F.File=${user.home}/test.log

You may also like to use log4j socket appender, which sends the logging output to remote server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜