开发者

Where the log stream goes?

开发者 https://www.devze.com 2023-01-28 10:52 出处:网络
when an app is started, not from the console but from an开发者_如何学JAVA UI icon, where the standard stream goes, I mean can I for example see this log? Where the plain old System.out directs to as a

when an app is started, not from the console but from an开发者_如何学JAVA UI icon, where the standard stream goes, I mean can I for example see this log? Where the plain old System.out directs to as a "default" ?


As Angus said, without a console you don't get output.

Once you've launched your application as a GUI, you can set the System.out field to log to another destination (rather than a TTY or a console), by using System.setOut. In that way you can write to a file by passing:

System.setOut(new PrintStream(path_to_a_file));

However, this is not advised.

The best thing you can do is to use a logging framework such as log4j or SLF4J, and perform logging (to a file, network host or console) that way.


If the app doesn't have a console then generally standard output doesn't go anywhere.

0

精彩评论

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