Java Log Exception logException(Throwable t, Logger log, Level level)

Here you can find the source of logException(Throwable t, Logger log, Level level)

Description

log Exception

License

Open Source License

Declaration

public static void logException(Throwable t, Logger log, Level level) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    public static void logException(Throwable t, Logger log, Level level) {
        String msg = t.getMessage() + "\n" + backtraceToString(t);
        log.log(level, msg);/*from  w  w  w .ja va  2  s .  c  o m*/
    }

    public static String backtraceToString(Throwable t) {
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        return sw.toString();
    }
}

Related

  1. logException(Logger logger, Level logLevel, Exception e)
  2. logException(Logger logger, String message, Throwable t)
  3. logException(Logger logger, Throwable t)
  4. LogException(String description, Throwable e)
  5. logException(String msg, Exception ex)
  6. logStackTrace(Logger log, Throwable e)
  7. logStackTrace(Throwable e, Logger logger)