简体   繁体   English

客户端应用程序中的Java登录

[英]Java logging in client application

I've made a small desktop application in java for OS X. I've packaged in into a .app using JarBundler. 我已经在OS X的Java中制作了一个小型桌面应用程序。使用JarBundler将其打包为.app。 Everything runs fine on my computer. 在我的计算机上一切正常。

When I send the .app to someone else (also running a mac), the app opens and closes immediately. 当我将.app发送给其他人(也正在运行Mac)时,该应用会立即打开和关闭。 Is there a log file of some kind I can get from their computer (which I have full access to). 我可以从他们的计算机上获取某种日志文件(我可以完全访问)。 Is there a way to get System.out.println statements or similar to show up in that file? 有没有办法让System.out.println语句或类似的语句显示在该文件中?

从控制台执行应用程序,从那里将所有错误打印到标准错误流。

Please avoid using System.out.println() statements on the application. 请避免在应用程序上使用System.out.println()语句。 The method is synchronized and results in poor performance. 该方法是同步的,并导致性能不佳。 Not to mention you may not be able to retrieve the statements based on who captures the console. 更不用说您可能无法根据捕获控制台的人员来检索语句。

Use a logging solution like sl4j and back it up with a logger like log4j with a file appender . 使用诸如sl4j之类的日志记录解决方案,并使用诸如log4j之类的带有文件附加器的记录器对其进行备份。 The file appender writes to a file and you can get your debug statements / stack traces from there. 文件附加器将写入文件,您可以从那里获取调试语句/堆栈跟踪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM