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

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

本文整理了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

  1. /**
  2. * Log a message at level WARN according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the WARN level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argArray
  13. * an array of arguments
  14. */
  15. @Override
  16. public void warn(String format, Object... argArray) {
  17. if (logger.isEnabledFor(Level.WARN)) {
  18. FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
  19. logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  20. }
  21. }

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

  1. /**
  2. * Log a message at level DEBUG according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the DEBUG level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param arguments an array of arguments
  13. */
  14. @Override
  15. public void debug(String format, Object... arguments) {
  16. if (logger.isDebugEnabled()) {
  17. FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
  18. logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
  19. }
  20. }

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

  1. /**
  2. * Log a message at level WARN according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the WARN level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argArray
  13. * an array of arguments
  14. */
  15. public void warn(String format, Object... argArray) {
  16. if (logger.isEnabledFor(Level.WARN)) {
  17. FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
  18. logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  19. }
  20. }

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

  1. /**
  2. * Log a message at level ERROR according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the ERROR level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argArray
  13. * an array of arguments
  14. */
  15. public void error(String format, Object... argArray) {
  16. if (logger.isEnabledFor(Level.ERROR)) {
  17. FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
  18. logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  19. }
  20. }

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

  1. /**
  2. * Log a message at the WARN level according to the specified format and
  3. * argument.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the WARN level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param arg
  13. * the argument
  14. */
  15. @Override
  16. public void warn(String format, Object arg) {
  17. if (logger.isEnabledFor(Level.WARN)) {
  18. FormattingTuple ft = MessageFormatter.format(format, arg);
  19. logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  20. }
  21. }

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

  1. /**
  2. * Log a message at level INFO according to the specified format and argument.
  3. *
  4. * <p>
  5. * This form avoids superfluous object creation when the logger is disabled
  6. * for the INFO level.
  7. * </p>
  8. *
  9. * @param format
  10. * the format string
  11. * @param arg
  12. * the argument
  13. */
  14. @Override
  15. public void info(String format, Object arg) {
  16. if (logger.isInfoEnabled()) {
  17. FormattingTuple ft = MessageFormatter.format(format, arg);
  18. logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
  19. }
  20. }

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

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

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

  1. /**
  2. * Log a message at the ERROR level according to the specified format and
  3. * argument.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the ERROR level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param arg
  13. * the argument
  14. */
  15. @Override
  16. public void error(String format, Object arg) {
  17. if (logger.isEnabledFor(Level.ERROR)) {
  18. FormattingTuple ft = MessageFormatter.format(format, arg);
  19. logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  20. }
  21. }

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

  1. /**
  2. * Log a message at level INFO according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the INFO level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argArray
  13. * an array of arguments
  14. */
  15. @Override
  16. public void info(String format, Object... argArray) {
  17. if (logger.isInfoEnabled()) {
  18. FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
  19. logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
  20. }
  21. }

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

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

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

  1. /**
  2. * Log a message at level ERROR according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the ERROR level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argArray
  13. * an array of arguments
  14. */
  15. @Override
  16. public void error(String format, Object... argArray) {
  17. if (logger.isEnabledFor(Level.ERROR)) {
  18. FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
  19. logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  20. }
  21. }

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

  1. /**
  2. * Log a message at level DEBUG according to the specified format and
  3. * argument.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for level DEBUG.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param arg
  13. * the argument
  14. */
  15. @Override
  16. public void debug(String format, Object arg) {
  17. if (logger.isDebugEnabled()) {
  18. FormattingTuple ft = MessageFormatter.format(format, arg);
  19. logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
  20. }
  21. }

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

  1. /**
  2. * Log a message at the ERROR level according to the specified format and
  3. * argument.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the ERROR level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param arg
  13. * the argument
  14. */
  15. public void error(String format, Object arg) {
  16. if (logger.isEnabledFor(Level.ERROR)) {
  17. FormattingTuple ft = MessageFormatter.format(format, arg);
  18. logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  19. }
  20. }

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

  1. /**
  2. * Log a message at the WARN level according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the WARN level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argA
  13. * the first argument
  14. * @param argB
  15. * the second argument
  16. */
  17. @Override
  18. public void warn(String format, Object argA, Object argB) {
  19. if (logger.isEnabledFor(Level.WARN)) {
  20. FormattingTuple ft = MessageFormatter.format(format, argA, argB);
  21. logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  22. }
  23. }

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

  1. /**
  2. * Log a message at level DEBUG according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the DEBUG level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argA
  13. * the first argument
  14. * @param argB
  15. * the second argument
  16. */
  17. @Override
  18. public void debug(String format, Object argA, Object argB) {
  19. if (logger.isDebugEnabled()) {
  20. FormattingTuple ft = MessageFormatter.format(format, argA, argB);
  21. logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
  22. }
  23. }

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

  1. /**
  2. * Log a message at the WARN level according to the specified format and
  3. * argument.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the WARN level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param arg
  13. * the argument
  14. */
  15. public void warn(String format, Object arg) {
  16. if (logger.isEnabledFor(Level.WARN)) {
  17. FormattingTuple ft = MessageFormatter.format(format, arg);
  18. logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
  19. }
  20. }

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

  1. /**
  2. * Log a message at the ERROR level according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the ERROR level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argA
  13. * the first argument
  14. * @param argB
  15. * the second argument
  16. */
  17. @Override
  18. public void error(String format, Object argA, Object argB) {
  19. if (logger.isEnabledFor(Level.ERROR)) {
  20. FormattingTuple ft = MessageFormatter.format(format, argA, argB);
  21. logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  22. }
  23. }

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

  1. /**
  2. * Log a message at the INFO level according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the INFO level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param argA
  13. * the first argument
  14. * @param argB
  15. * the second argument
  16. */
  17. @Override
  18. public void info(String format, Object argA, Object argB) {
  19. if (logger.isInfoEnabled()) {
  20. FormattingTuple ft = MessageFormatter.format(format, argA, argB);
  21. logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
  22. }
  23. }

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

  1. /**
  2. * Log a message at the ERROR level according to the specified format and
  3. * arguments.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the ERROR level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param arg1
  13. * the first argument
  14. * @param arg2
  15. * the second argument
  16. */
  17. public void error(String format, Object arg1, Object arg2) {
  18. if (logger.isEnabledFor(Level.ERROR)) {
  19. FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
  20. logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  21. }
  22. }

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

  1. /**
  2. * Log a message at the ERROR level according to the specified format and
  3. * argument.
  4. *
  5. * <p>
  6. * This form avoids superfluous object creation when the logger is disabled
  7. * for the ERROR level.
  8. * </p>
  9. *
  10. * @param format
  11. * the format string
  12. * @param arg
  13. * the argument
  14. */
  15. @Override
  16. public void error(String format, Object arg) {
  17. if (logger.isEnabledFor(Level.ERROR)) {
  18. FormattingTuple ft = MessageFormatter.format(format, arg);
  19. logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
  20. }
  21. }

相关文章