jvm default print information on how to console output to a log inside

private  static ByteArrayOutputStream baos = new ByteArrayOutputStream()

public static void main(String[] args) {
   ;


   try {
      System.out.println(1/0);
   } catch (Exception e) {
      toLog(e);
   }





}

private static void toLog(Exception e) {
   e.printStackTrace(new PrintStream(baos));
   String exception = baos.toString();
   System.out.println("baos:" + exception);
}

 

Published 316 original articles · won praise 33 · views 210 000 +

Guess you like

Origin blog.csdn.net/yz18931904/article/details/104174608