Java Log Exception logStackTrace(Throwable e, Logger logger)

Here you can find the source of logStackTrace(Throwable e, Logger logger)

Description

log Stack Trace

License

Open Source License

Declaration

public static void logStackTrace(Throwable e, Logger logger) 

Method Source Code


//package com.java2s;
/*/*from   w  ww.  j a  v  a2 s.c  om*/
 * Copyright 2012-13 Fraunhofer ISE
 *
 * This file is part of jDLMS.
 * For more information visit http://www.openmuc.org
 *
 * jDLMS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * jDLMS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with jDLMS.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

import java.io.PrintWriter;
import java.io.StringWriter;
import org.slf4j.Logger;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

public class Main {
    private static Marker COMMUNICATION = MarkerFactory.getMarker("Communication");

    public static void logStackTrace(Throwable e, Logger logger) {
        if (logger.isDebugEnabled()) {
            StringWriter sw = new StringWriter();
            e.printStackTrace(new PrintWriter(sw));
            logger.debug(COMMUNICATION, sw.toString());
        }
    }
}

Related

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