You could use raw find/replace functionality in source code files to comment out (or remove) statements, but whatever regular expression can be easily broken, so maybe you'd better be aware of logging frameworks like log4j or slf4j.
Big picture first: instead of using the usual System.out.println()
, you'll end up using a line of code like:
logger.debug("Just entered main");
The logging framework can be configured with a simple property file, so you can have multiple appenders (console, file, database, whatever) and shut down each one separately on demand (for example the console appender). To switch to a logging API you still have to perform raw find/replace on source files, and possibly fix a couple of things by hand, either whithin your IDE, or with a command like:
find src/ -name '*.java' | \
xargs sed -i -e 's/System.out.println/logger.verbose/g'