The other day, I was trying to debug some Java code that I was running with ColdFusion by using System.out.println() and System.err.println(). The first writes to standard out, and the second to standard error, which, in Java, are accessible as two static PrintStreams contained within the System object. Typically, writing to either of these streams will result in output to your console or to a log file. I’m not sure where the output was actually going when I started JRun with the default “jrun” executable, but it wasn’t immediately obvious and I wasn’t able to find it. To fix the issue, I wrote a script to start JRun instead, which redirects the standard out and standard error streams to specific log files. The script is only a few lines, and looks like this:
#!/bin/bash LOGDIR="/home/cantrell/Unix/JRun4/logs" ./jrun -start default 1>$LOGDIR/default-out.log 2>$LOGDIR/default-err.log
I saved the file in JRun’s bin directory, made it executable (chmod 755), and now when I use it to start JRun rather than the “jrun” executable, standard out and standard error are redirected to their respective log files. As you may have already guessed, the “1″ in the command above indicates standard out, and the “2″ indicates standard error. The greater-than symbols simply indicate redirection. This script will work on any Unix system (including OS X), but will not work on Windows.