Examples of LoggerContext


Examples of org.apache.logging.log4j.core.LoggerContext

    @Override
    public List<LoggerContext> getLoggerContexts() {
        final List<LoggerContext> list = new ArrayList<LoggerContext>();
        final Collection<AtomicReference<WeakReference<LoggerContext>>> coll = CONTEXT_MAP.values();
        for (final AtomicReference<WeakReference<LoggerContext>> ref : coll) {
            final LoggerContext ctx = ref.get().get();
            if (ctx != null) {
                list.add(ctx);
            }
        }
        return Collections.unmodifiableList(list);
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

                while (parent != null) {

                    ref = CONTEXT_MAP.get(parent.toString());
                    if (ref != null) {
                        final WeakReference<LoggerContext> r = ref.get();
                        LoggerContext ctx = r.get();
                        if (ctx != null) {
                            return ctx;
                        }
                    }
                    parent = parent.getParent();
                    /*  In Tomcat 6 the parent of the JSP classloader is the webapp classloader which would be
                    configured by the WebAppContextListener. The WebAppClassLoader is also the ThreadContextClassLoader.
                    In JBoss 5 the parent of the JSP ClassLoader is the WebAppClassLoader which is also the
                    ThreadContextClassLoader. However, the parent of the WebAppClassLoader is the ClassLoader
                    that is configured by the WebAppContextListener.

                    ClassLoader threadLoader = null;
                    try {
                        threadLoader = Thread.currentThread().getContextClassLoader();
                    } catch (Exception ex) {
                        // Ignore SecurityException
                    }
                    if (threadLoader != null && threadLoader == parent) {
                        break;
                    } else {
                        parent = parent.getParent();
                    } */
                }
            }
            LoggerContext ctx = new LoggerContext(name, null, configLocation);
            final AtomicReference<WeakReference<LoggerContext>> r =
                new AtomicReference<WeakReference<LoggerContext>>();
            r.set(new WeakReference<LoggerContext>(ctx));
            CONTEXT_MAP.putIfAbsent(loader.toString(), r);
            ctx = CONTEXT_MAP.get(name).get().get();
            return ctx;
        } else {
            final WeakReference<LoggerContext> r = ref.get();
            LoggerContext ctx = r.get();
            if (ctx != null) {
                return ctx;
            }
            ctx = new LoggerContext(name, null, configLocation);
            ref.compareAndSet(r, new WeakReference<LoggerContext>(ctx));
            return ctx;
        }
    }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

            LOGGER.debug("Unable to install security manager", ex);
        }
    }

    private LoggerContext getDefault() {
        final LoggerContext ctx = CONTEXT.get();
        if (ctx != null) {
            return ctx;
        }
        CONTEXT.compareAndSet(null, new LoggerContext("Default"));
        return CONTEXT.get();
    }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

    private static final LoggerContext CONTEXT = new LoggerContext("Default");

    @Override
    public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) {

        final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
        return ctx != null ? ctx : CONTEXT;
    }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

    @Override
    public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext,
                                    URI configLocation) {

        final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
        return ctx != null ? ctx : CONTEXT;
    }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

     * for the caller if a more appropriate Context can be determined.
     * @return The LoggerContext.
     */
    @Override
    public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) {
        final LoggerContext ctx = selector.getContext(fqcn, loader, currentContext);
        if (ctx.getStatus() == LoggerContext.Status.INITIALIZED) {
            ctx.start();
        }
        return ctx;
    }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

    @Override
    public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext,
                                    URI configLocation) {

        final LoggerContext lc = ContextAnchor.THREAD_CONTEXT.get();
        if (lc != null) {
            return lc;
        }

        String loggingContextName = null;
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

        if (name == null) {
            LOGGER.error("A context name is required to locate a LoggerContext");
            return null;
        }
        if (!CONTEXT_MAP.containsKey(name)) {
            final LoggerContext ctx = new LoggerContext(name, null, configLocation);
            CONTEXT_MAP.putIfAbsent(name, ctx);
        }
        return CONTEXT_MAP.get(name);
    }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

     * @return The LoggerContext.
     */
    @Override
    public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext,
            URI configLocation) {
        final LoggerContext ctx = selector.getContext(fqcn, loader, currentContext, configLocation);
        if (ctx.getStatus() == LoggerContext.Status.INITIALIZED) {
            ctx.start();
        }
        return ctx;
    }
View Full Code Here

Examples of org.apache.logging.log4j.spi.LoggerContext

    private final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<String, Object>();

    @Override
    public Log getInstance(final String name) throws LogConfigurationException {
        final LoggerContext context = PrivateManager.getContext();
        final ConcurrentMap<String, Log> loggers = getLoggersMap();
        if (loggers.containsKey(name)) {
            return loggers.get(name);
        }
        final org.apache.logging.log4j.Logger logger = PrivateManager.getLogger(name);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.