hello all, is there a way to get a log of all the errors that are displayed in the ms-dos box when an action is performed that causes an error? its giving me a whole bunch of errors from the superclass names, but i think it displays what i need to know as one of the first ones that get wiped out of the screen thanks
Hi Jonny, When you catch the exception, there instead of doing printStackTrace(), you can use the other two versions of this method, which accept a printWriter or a printStream object. I tried writing some example and here is the code :
This would write over the log file every time the program is run.
jonny, What you may want to do is simply redirect System.err to print to a text file rather than the console. The System class provides a method called setErr that allows you to do just that.This creates a text file called err.txt (you could name it anything you'd like) with these contents:
If you'd like a further explanation of I/O in Java and to learn more about the java.io package, I recommend that you take a look at The I/O Lesson of Sun's Java Tutorial and just ask your questions here at JavaRanch. Good Luck.
you might also want to try simply redirecting your output from the command window. java your_class 2> output.log this should redirect the err output to the file output.log I only have Windows 2000 here to verify it with, not sure if the command is compatible with older Windows (ie 9x)