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

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

Description

Log a message.

License

Apache License

Parameter

Parameter Description
format Message, formatted per SLF4J requirements
arguments Arguments to substitute into the message before logging

Declaration

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

Method Source Code


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

import org.slf4j.Logger;
import org.slf4j.helpers.MessageFormatter;

public class Main {
    private static Logger logger;

    /**/*w ww .  ja  v  a 2  s  .c  om*/
     * Log a message. If a logger has been specified, log the message at INFO level. Otherwise the message is logged
     * to System.out.
     * @param format Message, formatted per SLF4J requirements
     * @param arguments Arguments to substitute into the message before logging
     */
    public static void log(String format, Object... arguments) {
        if (null != logger) {
            logger.info(format, arguments);
        } else {
            System.out.println(MessageFormatter.arrayFormat(format, arguments).getMessage());
        }
    }
}

Related

  1. interruptCurrentThreadWithLog(Logger logger)
  2. isLoggable(final Logger logger, final Level level)
  3. isSlf4jPresent()
  4. log(Logger logger, int logLevel, String value)
  5. log(Logger logger, Throwable t)
  6. log(String message)
  7. logAndIdError(Logger log, String errorMessage)
  8. logArgs(final Logger logger, final Object[] args)
  9. logBind(Logger log, int index, Object value)