Secondly, the more effective way is to keep all the debug log message of the console in a file for back trace. The easiest way is to redirect the eclipse console output to a file. For this do the following settings in eclipse:
Run (menu)-> Run Configuration -> Common (tab) -> (under) Standard Input and Output -> Check File and provide the path for the log file.
Also in some specific scenario when you want to dump the output of your program to a file another way is to set the output stream of your program like this:
OutputStream os = new FileOutputStream("C:\\test\\log.txt");
System.setOut( new PrintStream(os));
System.setErr( new PrintStream(os));
System.out.println("test message");
System.err.println("error message");
OutputStream os = new FileOutputStream("C:\\test\\log.txt");
System.setOut( new PrintStream(os));
System.setErr( new PrintStream(os));
System.out.println("test message");
System.err.println("error message");
No comments:
Post a Comment