public Log4jLog(String name) { this.logger = loggerContext.getLogger(name); }
/** * Detects if a Logger with the specified name exists. This is a convenience method for porting from version 1. * * @param name The Logger name to search for. * @return true if the Logger exists, false otherwise. * @see LoggerContext#hasLogger(String) */ public static boolean exists(final String name) { return getContext().hasLogger(name); }
/** * Gets the current {@link ServletContext} if it has already been assigned to a LoggerContext's external context. * * @return the current ServletContext attached to a LoggerContext or {@code null} if none could be found * @since 2.1 */ public static ServletContext getServletContext() { org.apache.logging.log4j.spi.LoggerContext lc = ContextAnchor.THREAD_CONTEXT.get(); if (lc == null) { lc = LogManager.getContext(false); } return lc == null ? null : lc.getExternalContext() instanceof ServletContext ? (ServletContext) lc.getExternalContext() : null; } }
/** * Returns a Logger with the specified name. * * @param fqcn The fully qualified class name of the class that this method is a member of. * @param name The logger name. * @return The Logger. */ protected static Logger getLogger(final String fqcn, final String name) { return factory.getContext(fqcn, null, null, false).getLogger(name); }
/** * Detects if a Logger with the specified name exists. This is a convenience method for porting from version 1. * * @param name The Logger name to search for. * @return true if the Logger exists, false otherwise. * @see LoggerContext#hasLogger(String) */ public static boolean exists(final String name) { return getContext().hasLogger(name); }
@Override protected Logger newLogger(final String name, final LoggerContext context) { final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name; return new Log4jLogger(context.getLogger(key), name); }
public boolean exists(final String name) { return PrivateManager.getContext().hasLogger(name); }
/** * Always treat de-serialization as a full-blown constructor, by validating the final state of * the de-serialized object. */ private void readObject(final ObjectInputStream aInputStream) throws ClassNotFoundException, IOException { // always perform the default de-serialization first aInputStream.defaultReadObject(); logger = LogManager.getContext().getLogger(name); converter = createConverter(); }
public boolean exists(String name) { return PrivateManager.getContext().hasLogger(name); }
/** * Returns a Logger with the specified name. * * @param name The logger name. If null the name of the calling class will be used. * @return The Logger. * @throws UnsupportedOperationException if {@code name} is {@code null} and the calling class cannot be determined. */ public static Logger getLogger(final String name) { return name != null ? getContext(false).getLogger(name) : getLogger(StackLocatorUtil.getCallerClass(2)); }
/** * Returns a Logger with the specified name. * * @param name The logger name. If null the name of the calling class will be used. * @param messageFactory The message factory is used only when creating a logger, subsequent use does not change the * logger but will log a warning if mismatched. * @return The Logger. * @throws UnsupportedOperationException if {@code name} is {@code null} and the calling class cannot be determined. */ public static Logger getLogger(final String name, final MessageFactory messageFactory) { return name != null ? getContext(false).getLogger(name, messageFactory) : getLogger( StackLocatorUtil.getCallerClass(2), messageFactory); }
/** * Returns a Logger using the fully qualified name of the Class as the Logger name. * * @param clazz The Class whose name should be used as the Logger name. If null it will default to the calling * class. * @return The Logger. * @throws UnsupportedOperationException if {@code clazz} is {@code null} and the calling class cannot be * determined. */ public static Logger getLogger(final Class<?> clazz) { final Class<?> cls = callerClass(clazz); return getContext(cls.getClassLoader(), false).getLogger(toLoggerName(cls)); }
/** * Returns a Logger using the fully qualified name of the Class as the Logger name. * * @param clazz The Class whose name should be used as the Logger name. If null it will default to the calling * class. * @param messageFactory The message factory is used only when creating a logger, subsequent use does not change the * logger but will log a warning if mismatched. * @return The Logger. * @throws UnsupportedOperationException if {@code clazz} is {@code null} and the calling class cannot be * determined. */ public static Logger getLogger(final Class<?> clazz, final MessageFactory messageFactory) { final Class<?> cls = callerClass(clazz); return getContext(cls.getClassLoader(), false).getLogger(toLoggerName(cls), messageFactory); }
synchronized (PluginManager.class) { final LoggerContext loggerContext = LogManager.getContext(pluginLoader, false, path.toUri()); loggerContext.getLogger("To avoid LOG4J2-1094");
@Override protected Log newLogger(final String name, final LoggerContext context) { return new Log4jLog(context.getLogger(name)); }
public Log4jLog(String name) { this.logger = LOGGER_CONTEXT.getLogger(name); }
public Log4jLog(String name) { this.logger = loggerContext.getLogger(name); }
public Log4jLog(String name) { this.logger = loggerContext.getLogger(name); }
@Override protected Logger newLogger(final String name, final LoggerContext context) { final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name; return new Log4jLogger(markerFactory, context.getLogger(key), name); }
/** * Returns a Logger with the specified name. * * @param fqcn The fully qualified class name of the class that this method is a member of. * @param name The logger name. * @return The Logger. */ protected static Logger getLogger(final String fqcn, final String name) { return factory.getContext(fqcn, null, null, false).getLogger(name); }