/** * Creates a new LogConfigurationTask. */ public LogConfigurationTask() { this(LoggerFactory.getILoggerFactory()); }
LogConfigurator(String configDir, String childLogbackConfigFile) { this.configDir = configDir; this.childLogbackConfigFile = childLogbackConfigFile; this.loggerFactory = LoggerFactory.getILoggerFactory(); }
public Slf4jLogProvider() { this( LoggerFactory.getILoggerFactory() ); }
Slf4JLoggerFactory(boolean failIfNOP) { assert failIfNOP; // Should be always called with true. if (LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) { throw new NoClassDefFoundError("NOPLoggerFactory not supported"); } }
Slf4JLoggerFactory(boolean failIfNOP) { assert failIfNOP; // Should be always called with true. if (LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) { throw new NoClassDefFoundError("NOPLoggerFactory not supported"); } }
@Override protected StatusManager getStatusManager(HttpServletRequest req, HttpServletResponse resp) { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); return lc.getStatusManager(); }
@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"; }
/** * 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); }
public Slf4jLoggerFactory() { LoggerFactory.getILoggerFactory(); doRegister(); }
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; } }
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"); }
@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(); } }
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); }
/** * 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)); }
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); } } }
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(); } } }
@Override public void contextDestroyed(ServletContextEvent event) { Platform.getInstance().doStop(); LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); loggerContext.stop(); }
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(); }
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); rootLogger.detachAndStopAllAppenders();
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); rootLogger.detachAndStopAllAppenders();