Java slf4j Logger error(Class clz, String logStr, Throwable e)

Here you can find the source of error(Class clz, String logStr, Throwable e)

Description

Log an exception (throwable) at the ERROR level with an accompanying message.

License

Apache License

Parameter

Parameter Description
clz the class to be logged
logStr the message string to be logged
e the exception (throwable) to log

Declaration

public static void error(Class<?> clz, String logStr, Throwable e) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.slf4j.LoggerFactory;

public class Main {
    /**//from ww w .j a v  a 2s . c o m
     * Log a message at the ERROR level.
     *
     * @param clz    the class to be logged
     * @param logStr the message string to be logged
     */
    public static void error(Class<?> clz, String logStr) {
        LoggerFactory.getLogger(clz).error("[" + clz.getSimpleName() + "] " + logStr);
    }

    /**
     * Log an exception (throwable) at the ERROR level with an
     * accompanying message.
     *
     * @param clz    the class to be logged
     * @param logStr the message string to be logged
     * @param e      the exception (throwable) to log
     */
    public static void error(Class<?> clz, String logStr, Throwable e) {
        LoggerFactory.getLogger(clz).error("[" + clz.getSimpleName() + "] " + logStr, e);
    }
}

Related

  1. d d(String fmt, Object... args)
  2. debug(Logger logger, Exception e)
  3. debug(Logger logger, String format, Object... arguments)
  4. displayProperties(Logger log, Properties prop)
  5. dumpConfiguration(Map map, Logger log)
  6. error(final BundleContext b, final String msg, final Throwable t)
  7. error(Logger log, String fmt, String... args)
  8. error(Logger logger, Exception e)
  9. error(String errorMessage, Throwable e)