How do you redirect the console log to a file for Java Web Start in Mac OS X? [duplicate]
Possible Duplicate:
redirecting a java web start app logs to a file
How do you redirect the console log to a file for Java Web Start in Mac OS X? I am running an application as a Java Web Start, and I need the console data to persist; when the app closes, its console goes with it. Is there a way to redirect the console output to a log file?
For now, I am having my application stay open while I debug, but it would be nice to set this up for the unexpected.
It turns out the answer from How do I pipe the Java console output to a file? does work, but the log goes in the following location under OS X (which I have not found documented anywhere):
/~/Library/Caches/Java/log
If others happen to get into the problem, I'll let this other interesting bit of information.
The following link has additional information for deployment on OS X: http://www.ks.uiuc.edu/Research/biocore/javawebstart.shtml
and advises to set up in ‘~/.java/.deployment‘ the deployment.properties file with the following entries:
deployment.javaws.showConsole=false // I changed that to false for your need
// allow logging to some file
deployment.javaws.logToFile=true
// define said file to your heart's desire
deployment.javaws.logFileName=/tmp/webstart.txt // or ~/toto/whatever.lol if it suits you
This way, instead of ~/Library/Caches/Java/log you get what you wish.
System.setOut(new PrintStream("log.txt"));
and better way is using SL4J ( http://www.slf4j.org/ ) or other logger library.
精彩评论