LoggerContext getLoggerContext(final ClassLoader classLoader) { LoggerContext ctx; try { final int key = computeKey(classLoader); // If possible, avoid using Guava cache since the callable puts unwanted pressure on the garbage collector. ctx = builtContexts.get(key); if (ctx == null) { synchronized (this) { ctx = builtContexts.get(key); if (ctx == null) { ctx = doGetLoggerContext(classLoader, key); } } } } catch (ExecutionException e) { throw new MuleRuntimeException(createStaticMessage("Could not init logger context "), e); } if (ctx.getState() == LifeCycle.State.INITIALIZED) { synchronized (this) { if (ctx.getState() == LifeCycle.State.INITIALIZED) { ctx.start(); } } } return ctx; }
@Override public String getStatus() { return loggerContext.getState().toString(); }
private LoggerContext getCustomLoggerContext(Level log4jLevel) throws YggdrasilException { LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get(); if (ctx == null) { ctx = new CustomLoggerContext(); } if (ctx.getState() == LifeCycle.State.INITIALIZED) { ctx.start(new CustomLoggerConfiguration(log4jLevel)); } return ctx; }
@Override public LoggerContext getContext(String fqcn, ClassLoader loader, Object externalContext, boolean currentContext) { final LoggerContext ctx = customLoggerContext; if(externalContext != null && ctx.getExternalContext() == null) { ctx.setExternalContext(externalContext); } if(ctx.getState() == LifeCycle.State.INITIALIZED) { ctx.start(); } return ctx; }
/** * Loads the LoggerContext using the ContextSelector using the provided Configuration * @param fqcn The fully qualified class name of the caller. * @param loader The ClassLoader to use or null. * @param externalContext An external context (such as a ServletContext) to be associated with the LoggerContext. * @param currentContext If true returns the current Context, if false returns the Context appropriate * for the caller if a more appropriate Context can be determined. * @param configuration The Configuration. * @return The LoggerContext. */ public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext, final boolean currentContext, final Configuration configuration) { final LoggerContext ctx = selector.getContext(fqcn, loader, currentContext, null); if (externalContext != null && ctx.getExternalContext() == null) { ctx.setExternalContext(externalContext); } if (ctx.getState() == LifeCycle.State.INITIALIZED) { ContextAnchor.THREAD_CONTEXT.set(ctx); try { ctx.start(configuration); } finally { ContextAnchor.THREAD_CONTEXT.remove(); } } return ctx; }
LoggerContext getLoggerContext(final ClassLoader classLoader) { LoggerContext ctx; try { final int key = computeKey(classLoader); // If possible, avoid using Guava cache since the callable puts unwanted pressure on the garbage collector. ctx = builtContexts.get(key); if (ctx == null) { synchronized (this) { ctx = builtContexts.get(key); if (ctx == null) { ctx = doGetLoggerContext(classLoader, key); } } } } catch (ExecutionException e) { throw new MuleRuntimeException(createStaticMessage("Could not init logger context "), e); } if (ctx.getState() == LifeCycle.State.INITIALIZED) { synchronized (this) { if (ctx.getState() == LifeCycle.State.INITIALIZED) { ctx.start(); } } } return ctx; }
/** * Loads the LoggerContext using the ContextSelector. * @param fqcn The fully qualified class name of the caller. * @param loader The ClassLoader to use or null. * @param currentContext If true returns the current Context, if false returns the Context appropriate * for the caller if a more appropriate Context can be determined. * @param externalContext An external context (such as a ServletContext) to be associated with the LoggerContext. * @return The LoggerContext. */ @Override public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext, final boolean currentContext) { final LoggerContext ctx = selector.getContext(fqcn, loader, currentContext); if (externalContext != null && ctx.getExternalContext() == null) { ctx.setExternalContext(externalContext); } if (ctx.getState() == LifeCycle.State.INITIALIZED) { ctx.start(); } return ctx; }
ctx.setName(name); if (ctx.getState() == LifeCycle.State.INITIALIZED) { if ((configLocations != null && !configLocations.isEmpty())) { ContextAnchor.THREAD_CONTEXT.set(ctx);
@Override public LoggerContext getContext(String fqcn, ClassLoader loader, Object externalContext, boolean currentContext, URI configLocation, String name) { final LoggerContext ctx = customLoggerContext; if (externalContext != null && ctx.getExternalContext() == null) { ctx.setExternalContext(externalContext); } if (name != null) { ctx.setName(name); } if (ctx.getState() == LifeCycle.State.INITIALIZED) { if (configLocation != null || name != null) { THREAD_CONTEXT.set(ctx); final Configuration config = ConfigurationFactory.getInstance().getConfiguration(name, configLocation); StatusLogger.getLogger().debug("Starting LoggerContext[name={}] from configuration at {}", ctx.getName(), configLocation); ctx.start(config); THREAD_CONTEXT.remove(); } else { ctx.start(); } } return ctx; } }
/** * Loads the LoggerContext using the ContextSelector. * @param fqcn The fully qualified class name of the caller. * @param loader The ClassLoader to use or null. * @param externalContext An external context (such as a ServletContext) to be associated with the LoggerContext. * @param currentContext If true returns the current Context, if false returns the Context appropriate * for the caller if a more appropriate Context can be determined. * @param source The configuration source. * @return The LoggerContext. */ public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext, final boolean currentContext, final ConfigurationSource source) { final LoggerContext ctx = selector.getContext(fqcn, loader, currentContext, null); if (externalContext != null && ctx.getExternalContext() == null) { ctx.setExternalContext(externalContext); } if (ctx.getState() == LifeCycle.State.INITIALIZED) { if (source != null) { ContextAnchor.THREAD_CONTEXT.set(ctx); final Configuration config = ConfigurationFactory.getInstance().getConfiguration(ctx, source); LOGGER.debug("Starting LoggerContext[name={}] from configuration {}", ctx.getName(), source); ctx.start(config); ContextAnchor.THREAD_CONTEXT.remove(); } else { ctx.start(); } } return ctx; }
ctx.setName(name); if (ctx.getState() == LifeCycle.State.INITIALIZED) { if (configLocation != null || name != null) { ContextAnchor.THREAD_CONTEXT.set(ctx);