org.slf4j.LoggerFactory类的使用及代码示例

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

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

LoggerFactory介绍

[英]The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for log4j, logback and JDK 1.4 logging. Other implementations such as org.slf4j.impl.NOPLogger and org.slf4j.impl.SimpleLogger are also supported.

LoggerFactory is essentially a wrapper around an ILoggerFactory instance bound with LoggerFactory at compile time.

Please note that all methods in LoggerFactory are static.
[中]LoggerFactory是一个实用程序类,为各种日志API生成日志,最显著的是log4j、logback和JDK1.4日志。其他实现,如org。slf4j。impl。nologger和org。slf4j。impl。也支持SimpleLogger。
LoggerFactory本质上是编译时绑定了LoggerFactory的iLogger工厂实例的包装器。
请注意LoggerFactory中的所有方法都是静态的。

代码示例

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

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

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

/**
 * Creates a new LogConfigurationTask.
 */
public LogConfigurationTask() {
  this(LoggerFactory.getILoggerFactory());
}

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

private final static void performInitialization() {
  bind();
  if (INITIALIZATION_STATE == SUCCESSFUL_INITIALIZATION) {
    versionSanityCheck();
  }
}

代码示例来源:origin: ctripcorp/apollo

private void tryConfigCLogging() throws Exception {
 String appId = Foundation.app().getAppId();
 if (Strings.isNullOrEmpty(appId)) {
  logger.warn("App id is null or empty!");
  return;
 }
 LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
 Class clazz = Class.forName(cLoggingAppenderClass);
 Appender cLoggingAppender = (Appender) clazz.newInstance();
 ReflectionUtils.findMethod(clazz, "setAppId", String.class).invoke(cLoggingAppender, appId);
 ReflectionUtils.findMethod(clazz, "setServerIp", String.class)
   .invoke(cLoggingAppender, cloggingUrl());
 ReflectionUtils.findMethod(clazz, "setServerPort", int.class)
   .invoke(cLoggingAppender, Integer.parseInt(cloggingPort()));
 cLoggingAppender.setName("CentralLogging");
 cLoggingAppender.setContext(loggerContext);
 cLoggingAppender.start();
 ch.qos.logback.classic.Logger logger =
   (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("root");
 logger.addAppender(cLoggingAppender);
}

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

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

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

public Slf4jLogProvider()
{
  this( LoggerFactory.getILoggerFactory() );
}

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

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

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

LogConfigurator(String configDir, String childLogbackConfigFile) {
  this.configDir = configDir;
  this.childLogbackConfigFile = childLogbackConfigFile;
  this.loggerFactory = LoggerFactory.getILoggerFactory();
}

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

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

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

Slf4JLoggerFactory(boolean failIfNOP) {
  assert failIfNOP; // Should be always called with true.
  if (LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) {
    throw new NoClassDefFoundError("NOPLoggerFactory not supported");
  }
}

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

public SLF4JImpl(String loggerName){
  this.log = (LocationAwareLogger) LoggerFactory.getLogger(loggerName);
}

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

Slf4JLoggerFactory(boolean failIfNOP) {
  assert failIfNOP; // Should be always called with true.
  if (LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) {
    throw new NoClassDefFoundError("NOPLoggerFactory not supported");
  }
}

代码示例来源:origin: Netflix/zuul

public AccessLogPublisher(String loggerName, BiFunction<Channel, HttpRequest, String> requestIdProvider)
{
  this.logger = LoggerFactory.getLogger(loggerName);
  this.requestIdProvider = requestIdProvider;
}

代码示例来源:origin: ch.qos.logback/logback-classic

@Override
protected StatusManager getStatusManager(HttpServletRequest req, HttpServletResponse resp) {
  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
  return lc.getStatusManager();
}

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

SLF4JLogDelegate(final String name) {
 logger = LoggerFactory.getLogger(name);
}

代码示例来源:origin: ch.qos.logback/logback-classic

@Override
protected String getPageTitle(HttpServletRequest req, HttpServletResponse resp) {
  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
  return "<h2>Status messages for LoggerContext named [" + lc.getName() + "]</h2>\r\n";
}

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

public Logger(String name)
{
 log = LoggerFactory.getLogger(name);
}

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

/**
 * Return a logger named according to the name parameter using the
 * statically bound {@link ILoggerFactory} instance.
 * 
 * @param name
 *            The name of the logger.
 * @return logger
 */
public static Logger getLogger(String name) {
  ILoggerFactory iLoggerFactory = getILoggerFactory();
  return iLoggerFactory.getLogger(name);
}

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

public Logger(Class clazz)
{
 log = LoggerFactory.getLogger(clazz);
}

代码示例来源:origin: apache/rocketmq

public Slf4jLoggerFactory() {
  LoggerFactory.getILoggerFactory();
  doRegister();
}

相关文章