Java slf4j Logger warn(String format, Object... arguments)

Here you can find the source of warn(String format, Object... arguments)

Description

warn

License

Apache License

Declaration

public static void warn(String format, Object... arguments) 

Method Source Code


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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {

    public static void warn(String format, Object... arguments) {
        warn(innerGet(), format, arguments);
    }/*from ww w  . j a v a2 s. c  o  m*/

    public static void warn(Logger log, String format, Object... arguments) {
        log.warn(format, arguments);
    }

    public static void warn(Throwable e, String format, Object... arguments) {
        warn(innerGet(), e, format(format, arguments));
    }

    public static void warn(Logger log, Throwable e, String format, Object... arguments) {
        log.warn(format(format, arguments), e);
    }

    private static Logger innerGet() {
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        return LoggerFactory.getLogger(stackTrace[3].getClassName());
    }

    private static String format(String template, Object... values) {
        return String.format(template.replace("{}", "%s"), values);
    }
}

Related

  1. stringifyStackTrace(Exception e)
  2. testLogError(String errorMessage, Exception ex)
  3. traceCall(Class objectClass)
  4. traceLog(final Logger log, final String logMethodName, String logMsg)
  5. warn(Logger log, Object... args)
  6. warn(String message)
  7. warn(String msg)
  8. warn(String msg)
  9. warnOrDebug(Logger logger, String msg)