Friday 15 August 2014

Intercept System.out and prepend date time in Java -


Is this system out.print * and System.err.print * (in Java) to call and prepaid Is it possible for them to have a time stamp? Do not worry, we use the normal logging framework, but sometimes some sys.out exits and it would be good to know when this happens, then we can tie the proper log files.

You can do this.

Returns the "standard" output stream. First of all, if there is a security manager, Runtime Promotion ("Setio") is called with permission to see if its checkup method is reassign to the "standard" output stream.

  public class customprintstream printer stream {// override print methods here} System.setOut (New CustomPrintStream ());    

No comments:

Post a Comment