如何将控制台日志重定向到 Mac OS X 中的 Java Web Start 文件?

发布于 2024-12-01 16:55:27 字数 493 浏览 7 评论 0原文

可能的重复:
将 java web start 应用日志重定向到文件

如何将控制台日志重定向到 Mac OS X 中的 Java Web Start 文件?我正在将应用程序作为 Java Web Start 运行,并且需要保留控制台数据;当应用程序关闭时,其控制台也会随之关闭。有没有办法将控制台输出重定向到日志文件?

目前,我在调试时让应用程序保持打开状态,但最好针对意外情况进行设置。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伴随着你 2024-12-08 16:55:27

事实证明,答案来自 How do I Pipe Java 控制台输出到文件? 确实有效,但日志位于 OS X 下的以下位置(我没有在任何地方找到记录):

/~/Library/Caches/Java/log

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

じ违心 2024-12-08 16:55:27

如果其他人碰巧遇到这个问题,我会提供其他有趣的信息。

以下链接包含有关在 OS X 上部署的其他信息: http://www.ks .uiuc.edu/Research/biocore/javawebstart.shtml

并建议在“~/.java/.deployment”中设置包含以下条目的deployment.properties文件:

 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

这样,而不是~/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.

赠我空喜 2024-12-08 16:55:27
System.setOut(new PrintStream("log.txt"));

更好的方法是使用 SL4J ( http://www.slf4j.org/ ) 或其他记录器库。

System.setOut(new PrintStream("log.txt"));

and better way is using SL4J ( http://www.slf4j.org/ ) or other logger library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文