Refine search
if (!isAndroid()) { staticLoggerBinderPathSet = findPossibleStaticLoggerBinderPathSet(); reportMultipleBindingAmbiguity(staticLoggerBinderPathSet); StaticLoggerBinder.getSingleton(); INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION; reportActualBinding(staticLoggerBinderPathSet); if (messageContainsOrgSlf4jImplStaticLoggerBinder(msg)) { INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION; Util.report("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\"."); Util.report("Defaulting to no-operation (NOP) logger implementation"); Util.report("See " + NO_STATICLOGGERBINDER_URL + " for further details."); } else { failedBinding(ncde);
if (INITIALIZATION_STATE == UNINITIALIZED) { INITIALIZATION_STATE = ONGOING_INITIALIZATION; performInitialization(); return StaticLoggerBinder.getSingleton().getLoggerFactory(); case NOP_FALLBACK_INITIALIZATION: return NOP_FALLBACK_FACTORY;
private static void reportActualBinding(Set<URL> binderPathSet) { // binderPathSet can be null under Android if (binderPathSet != null && isAmbiguousStaticLoggerBinderPathSet(binderPathSet)) { Util.report("Actual binding is of type [" + StaticLoggerBinder.getSingleton().getLoggerFactoryClassStr() + "]"); } }
/** * Package access for testing purposes. */ static void reset() { SINGLETON = new StaticLoggerBinder(); SINGLETON.init(); }
/** * Construct a new DependencyCheckTask. */ public Purge() { super(); // Call this before Dependency Check Core starts logging anything - this way, all SLF4J messages from // core end up coming through this tasks logger StaticLoggerBinder.getSingleton().setTask(this); }
public static synchronized void init(File file) { if (IMPL_IN_USE != null) { return; } StaticLoggerBinder binder = StaticLoggerBinder.getSingleton(); Method init = null; try { if (binder.getLoggerFactoryClassStr().startsWith(LOGBACK_IMPL)) { IMPL_IN_USE = Class.forName(LOGBACK_CONFIG); init = IMPL_IN_USE.getDeclaredMethod("init", File.class); FILE = new File(file, LOGBACK_FILE); init.invoke(null, FILE); } else if (binder.getLoggerFactoryClassStr().startsWith(LOG4J_IMPL)) { IMPL_IN_USE = Class.forName(LOG4J_CONFIG); init = IMPL_IN_USE.getDeclaredMethod("init", File.class); FILE = new File(file, LOG4J_FILE); init.invoke(null, FILE); } else if (binder.getLoggerFactoryClassStr().startsWith(JDK14_IMPL)) { IMPL_IN_USE = Class.forName(JDK14_CONFIG); init = IMPL_IN_USE.getDeclaredMethod("init", File.class); FILE = new File(file, JDK14_FILE); init.invoke(null, FILE); } } catch (Exception e) { throw new RuntimeException(e); } LOGGER = LoggerFactory.getLogger(LogConfiguration.class); }
protected void initializeLogging() { String graviteeHome = System.getProperty(GRAVITEE_HOME_PROPERTY); String logbackConfiguration = graviteeHome + File.separator + "config" + File.separator + "logback.xml"; File logbackConfigurationfile = new File(logbackConfiguration); // If logback configuration available, load it, else, load default logback configuration if (logbackConfigurationfile.exists()) { System.setProperty("logback.configurationFile", logbackConfigurationfile.getAbsolutePath()); StaticLoggerBinder loggerBinder = StaticLoggerBinder.getSingleton(); LoggerContext loggerContext = (LoggerContext) loggerBinder.getLoggerFactory(); loggerContext.reset(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(loggerContext); try { configurator.doConfigure(logbackConfigurationfile); } catch( JoranException e ) { LoggerFactory.getLogger(this.getClass()).error("An error occurs while initializing logging system", e); } // Internal status data is printed in case of warnings or errors. StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); } }
StaticLoggerBinder.getSingleton().registerMavenLogger(getLog()); final Logger logger = LoggerFactory.getLogger(getClass()); compiler.setLogger(logger); compiler.setIssueMessageFormatter((issue, uriToProblem) -> {
/** * Returns the current logger-context. */ @VisibleForTesting static LoggerContext loggerContext() { ILoggerFactory factory = LoggerFactory.getILoggerFactory(); if (factory instanceof LoggerContext) { return (LoggerContext) factory; } // Pax-Logging registers a custom implementation of ILoggerFactory which hides logback; as a workaround // we set org.ops4j.pax.logging.StaticLogbackContext=true in system.properties and access it statically return (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory(); }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); ContextSelector selector = StaticLoggerBinder.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(); } } }
private final static void bind() { try { Set staticLoggerBinderPathSet = findPossibleStaticLoggerBinderPathSet(); reportMultipleBindingAmbiguity(staticLoggerBinderPathSet); StaticLoggerBinder.getSingleton(); INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION; reportActualBinding(staticLoggerBinderPathSet); emitSubstituteLoggerWarning(); } catch (NoClassDefFoundError ncde) { if (messageContainsOrgSlf4jImplStaticLoggerBinder(msg)) { INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION; Util.report("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\"."); Util.report("Defaulting to no-operation (NOP) logger implementation"); Util.report("See " + NO_STATICLOGGERBINDER_URL + " for further details."); } else {
private LoggerContext getLoggerContext() { ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory(); Assert.isInstanceOf(LoggerContext.class, factory, String.format( "LoggerFactory is not a Logback LoggerContext but Logback is on " + "the classpath. Either remove Logback or the competing " + "implementation (%s loaded from %s). If you are using " + "WebLogic you will need to add 'org.slf4j' to " + "prefer-application-packages in WEB-INF/weblogic.xml", factory.getClass(), getLocation(factory))); return (LoggerContext) factory; }
private final static void bind() { try { Set staticLoggerBinderPathSet = findPossibleStaticLoggerBinderPathSet(); reportMultipleBindingAmbiguity(staticLoggerBinderPathSet); StaticLoggerBinder.getSingleton(); INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION; reportActualBinding(staticLoggerBinderPathSet); fixSubstitutedLoggers(); } catch (NoClassDefFoundError ncde) { if (messageContainsOrgSlf4jImplStaticLoggerBinder(msg)) { INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION; Util.report("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\"."); Util.report("Defaulting to no-operation (NOP) logger implementation"); Util.report("See " + NO_STATICLOGGERBINDER_URL + " for further details."); } else {
/** * Releases the current factory and re-installs the original factory. */ public static final void release() { Log log = LOGS.get(LOGS.size() - 1); StaticLoggerBinder.getSingleton().setMavenLog(log); }
private final static StaticLoggerBinder getSingleton() { if (GET_SINGLETON_METHOD == GET_SINGLETON_INEXISTENT) { return StaticLoggerBinder.SINGLETON; } if (GET_SINGLETON_METHOD == GET_SINGLETON_EXISTS) { return StaticLoggerBinder.getSingleton(); } try { StaticLoggerBinder singleton = StaticLoggerBinder.getSingleton(); GET_SINGLETON_METHOD = GET_SINGLETON_EXISTS; return singleton; } catch (NoSuchMethodError nsme) { GET_SINGLETON_METHOD = GET_SINGLETON_INEXISTENT; return StaticLoggerBinder.SINGLETON; } }
/** * Initializes the {@link LogFactory} to use the {@link MavenLogAdapter}. The * specified {@link org.apache.maven.plugin.logging.Log} instance is used when * later initializing the individual log instances. * * @param log The {@link org.apache.maven.plugin.logging.Log} instance to use. */ public static final void initialize(Log log) { LOGS.add(StaticLoggerBinder.getSingleton().getMavenLog()); StaticLoggerBinder.getSingleton().setMavenLog(log); }
@Override public void setLog(Log log) { super.setLog(log); StaticLoggerBinder.getSingleton().setLog(log); }
@Override public final void execute() throws MojoExecutionException, MojoFailureException { StaticLoggerBinder staticLoggerBinder = StaticLoggerBinder.getSingleton(); staticLoggerBinder.setLog(getLog()); try { doExecute(); } finally { staticLoggerBinder.revokeLog(); } }
/** * Return the {@link ILoggerFactory} instance in use. * * <p> * ILoggerFactory instance is bound with this class at compile time. * * @return the ILoggerFactory instance in use */ public static ILoggerFactory getILoggerFactory() { if (INITIALIZATION_STATE == UNINITIALIZED) { INITIALIZATION_STATE = ONGOING_INITILIZATION; performInitialization(); } switch (INITIALIZATION_STATE) { case SUCCESSFUL_INITILIZATION: return getSingleton().getLoggerFactory(); case FAILED_INITILIZATION: throw new IllegalStateException(UNSUCCESSFUL_INIT_MSG); case ONGOING_INITILIZATION: // support re-entrant behavior. // See also http://bugzilla.slf4j.org/show_bug.cgi?id=106 return TEMP_FACTORY; } throw new IllegalStateException("Unreachable code"); } }
public void contextDestroyed(ServletContextEvent servletContextEvent) { String loggerContextName = null; try { Context ctx = JNDIUtil.getInitialContext(); loggerContextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME); } catch (NamingException ne) { } if (loggerContextName != null) { System.out.println("About to detach context named " + loggerContextName); ContextSelector selector = StaticLoggerBinder.getSingleton().getContextSelector(); LoggerContext context = selector.detachLoggerContext(loggerContextName); if (context != null) { Logger logger = context.getLogger(Logger.ROOT_LOGGER_NAME); logger.warn("Stopping logger context " + loggerContextName); // when the web-app is destroyed, its logger context should be stopped context.stop(); } else { System.out.println("No context named " + loggerContextName + " was found."); } } }