org.apache.log4j.Logger.log()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中org.apache.log4j.Logger.log()方法的一些代码示例,展示了Logger.log()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.log()方法的具体详情如下:
包路径:org.apache.log4j.Logger
类名称:Logger
方法名:log

Logger.log介绍

[英]Log a parameterized message at specified level.
[中]在指定级别记录参数化消息。

代码示例

代码示例来源:origin: netty/netty

/**
 * Log a message at level WARN according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the WARN level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argArray
 *          an array of arguments
 */
@Override
public void warn(String format, Object... argArray) {
  if (logger.isEnabledFor(Level.WARN)) {
    FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
    logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at level DEBUG according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the DEBUG level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arguments an array of arguments
 */
@Override
public void debug(String format, Object... arguments) {
  if (logger.isDebugEnabled()) {
    FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
    logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: org.slf4j/slf4j-log4j12

/**
 * Log a message at level WARN according to the specified format and
 * arguments.
 * 
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the WARN level.
 * </p>
 * 
 * @param format
 *          the format string
 * @param argArray
 *          an array of arguments
 */
public void warn(String format, Object... argArray) {
  if (logger.isEnabledFor(Level.WARN)) {
    FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
    logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: org.slf4j/slf4j-log4j12

/**
 * Log a message at level ERROR according to the specified format and
 * arguments.
 * 
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the ERROR level.
 * </p>
 * 
 * @param format
 *          the format string
 * @param argArray
 *          an array of arguments
 */
public void error(String format, Object... argArray) {
  if (logger.isEnabledFor(Level.ERROR)) {
    FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
    logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at the WARN level according to the specified format and
 * argument.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the WARN level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void warn(String format, Object arg) {
  if (logger.isEnabledFor(Level.WARN)) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at level INFO according to the specified format and argument.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the INFO level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void info(String format, Object arg) {
  if (logger.isInfoEnabled()) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: wildfly/wildfly

protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters, final Throwable thrown) {
  final org.apache.log4j.Level translatedLevel = translate(level);
  if (logger.isEnabledFor(translatedLevel)) try {
    logger.log(loggerClassName, translatedLevel, parameters == null ? String.format(format) : String.format(format, parameters), thrown);
  } catch (Throwable ignored) {}
}

代码示例来源:origin: netty/netty

/**
 * Log a message at the ERROR level according to the specified format and
 * argument.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the ERROR level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void error(String format, Object arg) {
  if (logger.isEnabledFor(Level.ERROR)) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at level INFO according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the INFO level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argArray
 *          an array of arguments
 */
@Override
public void info(String format, Object... argArray) {
  if (logger.isInfoEnabled()) {
    FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
    logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: wildfly/wildfly

protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
  final org.apache.log4j.Level translatedLevel = translate(level);
  if (logger.isEnabledFor(translatedLevel)) try {
    logger.log(loggerClassName, translatedLevel, parameters == null || parameters.length == 0 ? message : MessageFormat.format(String.valueOf(message), parameters), thrown);
  } catch (Throwable ignored) {}
}

代码示例来源:origin: netty/netty

/**
 * Log a message at level ERROR according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the ERROR level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argArray
 *          an array of arguments
 */
@Override
public void error(String format, Object... argArray) {
  if (logger.isEnabledFor(Level.ERROR)) {
    FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
    logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at level DEBUG according to the specified format and
 * argument.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for level DEBUG.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void debug(String format, Object arg) {
  if (logger.isDebugEnabled()) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: org.slf4j/slf4j-log4j12

/**
 * Log a message at the ERROR level according to the specified format and
 * argument.
 * 
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the ERROR level.
 * </p>
 * 
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
public void error(String format, Object arg) {
  if (logger.isEnabledFor(Level.ERROR)) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at the WARN level according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the WARN level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argA
 *          the first argument
 * @param argB
 *          the second argument
 */
@Override
public void warn(String format, Object argA, Object argB) {
  if (logger.isEnabledFor(Level.WARN)) {
    FormattingTuple ft = MessageFormatter.format(format, argA, argB);
    logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at level DEBUG according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the DEBUG level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argA
 *          the first argument
 * @param argB
 *          the second argument
 */
@Override
public void debug(String format, Object argA, Object argB) {
  if (logger.isDebugEnabled()) {
    FormattingTuple ft = MessageFormatter.format(format, argA, argB);
    logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: org.slf4j/slf4j-log4j12

/**
 * Log a message at the WARN level according to the specified format and
 * argument.
 * 
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the WARN level.
 * </p>
 * 
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
public void warn(String format, Object arg) {
  if (logger.isEnabledFor(Level.WARN)) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at the ERROR level according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the ERROR level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argA
 *          the first argument
 * @param argB
 *          the second argument
 */
@Override
public void error(String format, Object argA, Object argB) {
  if (logger.isEnabledFor(Level.ERROR)) {
    FormattingTuple ft = MessageFormatter.format(format, argA, argB);
    logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: netty/netty

/**
 * Log a message at the INFO level according to the specified format and
 * arguments.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the INFO level.
 * </p>
 *
 * @param format
 *          the format string
 * @param argA
 *          the first argument
 * @param argB
 *          the second argument
 */
@Override
public void info(String format, Object argA, Object argB) {
  if (logger.isInfoEnabled()) {
    FormattingTuple ft = MessageFormatter.format(format, argA, argB);
    logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: org.slf4j/slf4j-log4j12

/**
 * Log a message at the ERROR level according to the specified format and
 * arguments.
 * 
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the ERROR level.
 * </p>
 * 
 * @param format
 *          the format string
 * @param arg1
 *          the first argument
 * @param arg2
 *          the second argument
 */
public void error(String format, Object arg1, Object arg2) {
  if (logger.isEnabledFor(Level.ERROR)) {
    FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
    logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Log a message at the ERROR level according to the specified format and
 * argument.
 *
 * <p>
 * This form avoids superfluous object creation when the logger is disabled
 * for the ERROR level.
 * </p>
 *
 * @param format
 *          the format string
 * @param arg
 *          the argument
 */
@Override
public void error(String format, Object arg) {
  if (logger.isEnabledFor(Level.ERROR)) {
    FormattingTuple ft = MessageFormatter.format(format, arg);
    logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  }
}

相关文章