org.apache.logging.log4j.LogManager.getLogger()方法的使用及代码示例

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

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

LogManager.getLogger介绍

[英]Returns a Logger with the name of the calling class.
[中]返回带有调用类名称的记录器。

代码示例

代码示例来源:origin: alibaba/druid

@Override
public void setDataSourceLoggerName(String dataSourceLoggerName) {
  this.dataSourceLoggerName = dataSourceLoggerName;
  dataSourceLogger = LogManager.getLogger(dataSourceLoggerName);
}

代码示例来源:origin: alibaba/druid

@Override
public void setConnectionLoggerName(String connectionLoggerName) {
  this.connectionLoggerName = connectionLoggerName;
  connectionLogger = LogManager.getLogger(connectionLoggerName);
}

代码示例来源:origin: alibaba/druid

@Override
public void setStatementLoggerName(String statementLoggerName) {
  this.statementLoggerName = statementLoggerName;
  statementLogger = LogManager.getLogger(statementLoggerName);
}

代码示例来源:origin: alibaba/druid

@Override
public void setResultSetLoggerName(String resultSetLoggerName) {
  this.resultSetLoggerName = resultSetLoggerName;
  resultSetLogger = LogManager.getLogger(resultSetLoggerName);
}

代码示例来源:origin: alibaba/druid

public Log4j2Impl(String loggerName){
  log = LogManager.getLogger(loggerName);
}

代码示例来源:origin: eclipse-vertx/vert.x

Log4j2LogDelegate(final String name) {
 logger = (ExtendedLogger) org.apache.logging.log4j.LogManager.getLogger(name);
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public Logger getLogger(String key) {
  return new Log4j2Logger(LogManager.getLogger(key));
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public Logger getLogger(String key) {
  return new Log4j2Logger(LogManager.getLogger(key));
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public Logger getLogger(Class<?> key) {
  return new Log4j2Logger(LogManager.getLogger(key));
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public Logger getLogger(Class<?> key) {
  return new Log4j2Logger(LogManager.getLogger(key));
}

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

@Override
  public InternalLogger newInstance(String name) {
    return new Log4J2Logger(LogManager.getLogger(name));
  }
}

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

@Override
  public InternalLogger newInstance(String name) {
    return new Log4J2Logger(LogManager.getLogger(name));
  }
}

代码示例来源:origin: medcl/elasticsearch-analysis-ik

static public Logger getLogger(String prefix, Class<?> clazz) {
  return getLogger(prefix, LogManager.getLogger(clazz.getName()));
}

代码示例来源:origin: medcl/elasticsearch-analysis-ik

static public Logger getLogger(String name) {
  return getLogger("", LogManager.getLogger(name));
}

代码示例来源:origin: medcl/elasticsearch-analysis-ik

static public Logger getLogger(String prefix, String name) {
  return getLogger(prefix, LogManager.getLogger(name));
}

代码示例来源:origin: alibaba/nacos

@Override
  public Logger getLogger(String name) {
    try {
      return new Log4j2Logger(LogManager.getLogger(name));
    } catch (Throwable t) {
      LogLog.error("Failed to get Log4j2Logger", t);
      return new NopLogger();
    }
  }
}

代码示例来源:origin: alibaba/nacos

@Override
public Logger getLogger(Class<?> clazz) {
  try {
    return new Log4j2Logger(LogManager.getLogger(clazz));
  } catch (Throwable t) {
    LogLog.error("Failed to get Log4j2Logger", t);
    return new NopLogger();
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testOutputStreamAppenderToBufferedOutputStream() throws SQLException {
  final ByteArrayOutputStream out = new ByteArrayOutputStream();
  final OutputStream os = new BufferedOutputStream(out);
  final String name = getName(out);
  final Logger logger = LogManager.getLogger(name);
  addAppender(os, name);
  logger.error(TEST_MSG);
  final String actual = out.toString();
  Assert.assertTrue(actual, actual.contains(TEST_MSG));
}

代码示例来源:origin: apache/incubator-druid

@AfterClass
public static void tearDownStatic()
{
 final Logger logger = (Logger) LogManager.getLogger(
   LoggingRequestLogger.class);
 logger.removeAppender(appender);
 appender.stop();
}

代码示例来源:origin: apache/incubator-druid

@BeforeClass
public static void setUpStatic()
{
 appender = OutputStreamAppender
   .newBuilder()
   .setName("test stream")
   .setTarget(baos)
   .setLayout(JsonLayout.createLayout(false, true, false, true, true, StandardCharsets.UTF_8))
   .build();
 final Logger logger = (Logger)
   LogManager.getLogger(LoggingRequestLogger.class);
 appender.start();
 logger.addAppender(appender);
}

相关文章