debugging - Any way to turn on/off a println in java (verbose mode) -


is there way in java can make println appear when requested, not default? similar using "-v" in many programs give verbose mode, information on happening.

for example let's have if statement in loop, , simple println tells me whether if statement evaluates true each iteration of loop. there other way toggle on/off it's visibility other commenting out when don't need , uncomment when do? saving it, recompiling it, etc.

it make lot easier see going on in program, when want info. said, looking way implement "verbose" mode shows print statements, without having comment/uncomment save, recompile, etc. java have this?

your best choice use appropriate logger of kind (log4j example).

if that's not possible, can "consume" stdout , stderr using like...

printstream nullprintstream = new printstream(new outputstream() {     @override     public void write(int b) throws ioexception {     } }); system.seterr(nullprintstream); system.setout(nullprintstream); 

which prevent output begin printed. can use proxy process (using current stdout wrapped in proxy printstream) filter content if that's more appropriate...


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -