Java Log Exception logException(Logger logger, Throwable t)

Here you can find the source of logException(Logger logger, Throwable t)

Description

log Exception

License

Open Source License

Parameter

Parameter Description
logger the logger to use
t the exception to report

Declaration

public static void logException(Logger logger, Throwable t) 

Method Source Code


//package com.java2s;
/* /* w w  w .java2 s .c  o m*/
 * Copyright ?2009 Jean-Fran?ois Lamy
 * 
 * Licensed under the Open Software Licence, Version 3.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.opensource.org/licenses/osl-3.0.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

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

public class Main {
    /**
     * @param logger the logger to use
     * @param t the exception to report
     */
    public static void logException(Logger logger, Throwable t) {
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        logger.info(sw.toString());
    }
}

Related

  1. LogException(Exception ex)
  2. logException(final Throwable exception)
  3. logException(int type, String RID, String subRID, String propIndication, String error)
  4. logException(Logger logger, Level logLevel, Exception e)
  5. logException(Logger logger, String message, Throwable t)
  6. LogException(String description, Throwable e)
  7. logException(String msg, Exception ex)
  8. logException(Throwable t, Logger log, Level level)
  9. logStackTrace(Logger log, Throwable e)