Hi, i'm trying to use the System.err.println("...."); in my program in a catch block, but how do i specify the error stream in the java command when i invoke my program. by default, if i don't mention anything, i suppose the error stream is the same as the output stream. But i want to log into a file.. like an error log file. this is the instruction given by the java command help
-D<name>=<value> set a system property
can anyone pls identify the correct name of the error stream property?
i tried this to run my java program "Test.java", java -Derror=error.log Test.. one of my shots in the dark.. but no good. :-)
Hi, Thanks a ton for all the quick replies. I tried out your suggestions and got the thing. java Test > <filename> only redirects the System.out stream to the file given. And thankyou Ariel, i used your idea. PrintStream stream = new PrintStream(new FileOutputStream("err.log")); System.setErr(stream); System.err.println("inside the err stream");
all the System.err.print statements do get printed in the err.log file.
should work on most Windows machines as well as Unix, directing the error stream (but not standard output) to the file error.log.
There's another form which directs both standard out and errors to the same place:
Again, this should work on both Unix and Windows. Here the 1>output.log directs standard out to output.log, and 2>&1 directs errors to the same place as 1, the standard out. Of course both "error.log" and "output.log" can be replaced with whatever filenames you prefer. [ July 31, 2005: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding, Twister
subject: how to set the error stream using "java" option -D