Java on Mac OS X: Where is a Swing appplication's System.out and System.err written?

Java on Mac OS X Swing FAQ: I've written a Java/Swing application, and bundled it so it looks like a native Mac OS X application. When I run my application, if I am writing to System.out or System.err, where does this output go?

Answer: I just ran into this problem myself, and finally decided to dig into it. In short, if you write to System.out or System.err from a Java/Swing application running on a Mac OS X system, as shown in this example code:

public static void main(String[] args)
{
  System.out.println("SIMPLICITY: SYSTEM OUT");
  System.out.println("SIMPLICITY: SYSTEM ERR");
  new Simplicity();
}

the output is written/logged to this file:

/var/log/system.log

Java/Mac System.out/System.err output test

I just ran my program, and then used the Unix tail command to look at this system log file, and saw this output:

$ tail /var/log/system.log

Apr 20 11:18:04 Macintosh-2 [0x0-0x703703].com.devdaily.simplicity.Simplicity[28482]: SIMPLICITY: SYSTEM OUT
Apr 20 11:18:04 Macintosh-2 [0x0-0x703703].com.devdaily.simplicity.Simplicity[28482]: SIMPLICITY: SYSTEM ERR

All of that "Simplicity" stuff has to do with my class and package naming for this application, but the important thing is to see that this is where System.out and System.err are written/logged to on a Mac OS X system. I suspect that if you have a Java application on a Mac OS X system that won't start up properly it is also written to this same log file, but I don't know that to be true.

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.