PrintStream myStream = new PrintStream(System.out) { @Override public void println(String x) { super.println(System.currentTimeMillis() + ": " + x); } }; System.setOut(myStream); System.out.println("Hello World!"); ------------------------------------------------------------------------------- Output: 1420553422337: Hello World!
参考:http://stackoverflow.com/questions/27800326/hook-into-system-out-println-and-modify