NOTE: The ability to alter the value of System.out and other system streams may be removed or changed in the future.
How to Redirect Output for an AppletYou can enable Java logging for applets in Microsoft Internet Explorer. All output that is sent to System.out or System.err is written to a file named Javalog.txt, which is found in the C:\<windir>\Java folder (where <windir> represents your operating system).
To enable Java logging in Internet Explorer, follow these steps:
- On the Start menu, point to Settings, click Control Panel, and then click Internet Options.
- On the Advanced tab, in the Microsoft VM section, make sure that the Java logging enabled check box is selected.
How to Redirect Output for an ApplicationTo redirect output for Java applications, perform one of the following steps:
- Use the redirection operator (>) on the command line to redirect all standard output to a file. For example, to redirect all text output to a file named Myjavalog.txt, type the following command at a command prompt:jview MyJavaApp > myjavalog.txt
- Reassign System.out to programmatically direct the output to a file or pipe. The following code, which works for jview or wjview and Internet Explorer, demonstrates how to do this:
public class JavaLogger
public static void main (String args)
// Code that writes to System.out or System.err
String logdir = System.getProperty("java.home");
PrintStream ps = new PrintStream(
new BufferedOutputStream(new FileOutputStream(
new File(logdir,"javalog.txt"))), true);
catch (Exception e)
Article ID: 252021 - Last Review: Jun 14, 2006 - Revision: 1