org.slf4j.LoggerFactory.getILoggerFactory()方法的使用及代码示例

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

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

LoggerFactory.getILoggerFactory介绍

[英]Return the ILoggerFactory instance in use.

ILoggerFactory instance is bound with this class at compile time.
[中]返回正在使用的iLogger工厂实例。
iLogger工厂实例在编译时与此类绑定。

代码示例

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

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

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

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

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

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

代码示例来源: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: 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: ch.qos.logback/logback-classic

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

代码示例来源: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: 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/rocketmq

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

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

public static LoggerContext getLoggerContext() {
    if (loggerContext == null) {
      ILoggerFactory lcObject = LoggerFactory.getILoggerFactory();

      if (!(lcObject instanceof LoggerContext)) {
        throw new LogbackException(
          "Expected LOGBACK binding with SLF4J, but another log system has taken the place: "
            + lcObject.getClass().getSimpleName());
      }

      loggerContext = (LoggerContext)lcObject;
    }

    return loggerContext;
  }
}

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

private static void initLogback() throws JoranException {
  String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
  JoranConfigurator configurator = new JoranConfigurator();
  configurator.setContext(lc);
  lc.reset();
  configurator.doConfigure(rocketmqHome + "/conf/logback_tools.xml");
}

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

@Override
public void contextDestroyed(ServletContextEvent sce) {
  ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
  if (iLoggerFactory instanceof LoggerContext) {
    LoggerContext loggerContext = (LoggerContext) iLoggerFactory;
    contextAwareBase.setContext(loggerContext);
    StatusViaSLF4JLoggerFactory.addInfo("About to stop " + loggerContext.getClass().getCanonicalName() + " [" + loggerContext.getName() + "]", this);
    loggerContext.stop();
  }
}

代码示例来源: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: SonarSource/sonarqube

/**
 * Generally used to reset logback in logging tests
 */
public void resetFromXml(String xmlResourcePath) throws JoranException {
 LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
 JoranConfigurator configurator = new JoranConfigurator();
 configurator.setContext(context);
 context.reset();
 configurator.doConfigure(LogbackHelper.class.getResource(xmlResourcePath));
}

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

public static void addStatus(Status status) {
    ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
    if (iLoggerFactory instanceof LoggerContext) {
      ContextAwareBase contextAwareBase = new ContextAwareBase();
      LoggerContext loggerContext = (LoggerContext) iLoggerFactory;
      contextAwareBase.setContext(loggerContext);
      contextAwareBase.addStatus(status);
    }
  }
}

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

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
  ContextSelector selector = ContextSelectorStaticBinder.getSingleton().getContextSelector();
  ContextJNDISelector sel = null;
  if (selector instanceof ContextJNDISelector) {
    sel = (ContextJNDISelector) selector;
    sel.setLocalContext(lc);
  }
  try {
    chain.doFilter(request, response);
  } finally {
    if (sel != null) {
      sel.removeLocalContext();
    }
  }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public void contextDestroyed(ServletContextEvent event) {
 Platform.getInstance().doStop();
 LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
 loggerContext.stop();
}

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

protected static void doMain(Class<? extends SimpleSocketServer> serverClass, String argv[]) throws Exception {
  int port = -1;
  if (argv.length == 2) {
    port = parsePortNumber(argv[0]);
  } else {
    usage("Wrong number of arguments.");
  }
  String configFile = argv[1];
  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
  configureLC(lc, configFile);
  SimpleSocketServer sss = new SimpleSocketServer(lc, port);
  sss.start();
}

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

LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.detachAndStopAllAppenders();

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

LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.detachAndStopAllAppenders();

相关文章