try
{
FileOutputStream fout= new FileOutputStream("stdout.log");
FileOutputStream ferr= new FileOutputStream("stderr.log");
TeeOutputStream multiOut= new TeeOutputStream(System.out, fout);
TeeOutputStream multiErr= new TeeOutputStream(System.err, ferr);
PrintStream stdout= new PrintStream(multiOut);
PrintStream stderr= new PrintStream(multiErr);
System.setOut(stdout);
System.setErr(stderr);
}
catch (FileNotFoundException ex)
{
}