java - Do action when something is printed in System.err -


like in topic - trying action when printed error stream, code below not working:

try {     system.setout(new printstream("infolog.txt"));     system.seterr(new printstream(new fileoutputstream("errorlog.txt") {         public void write(int b) throws ioexception {             super.write(b);             error();         }         public void write(byte[] b) throws ioexception {             super.write(b);             error();         }     })); } catch (filenotfoundexception ex) {     logger.getlogger(housecalc.class.getname()).log(level.severe, null, ex); } 

is there way "catch" system.err stream , make action before gets printed file?

make sure override the appropriate methods. have @ source of printstream, because might calling each other. want way down.

write(char cbuf[], int off, int len) 

might 1 need.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -