Refine search
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doGetLogger(final String name) { Logger l = LogContext.getLogContext().getAttachment(name, KEY); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); Logger a = logger.attachIfAbsent(KEY, l); if (a == null) { return l; } else { return a; } }
/** * Gets the property configurator. If the {@link ConfigurationPersistence} does not exist a new one is created. * * @param logContext the log context used to find the property configurator or to attach it to. * * @return the property configurator */ public static ConfigurationPersistence getOrCreateConfigurationPersistence(final LogContext logContext) { final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME); ConfigurationPersistence result = (ConfigurationPersistence) root.getAttachment(Configurator.ATTACHMENT_KEY); if (result == null) { result = new ConfigurationPersistence(logContext); ConfigurationPersistence existing = (ConfigurationPersistence) root.attachIfAbsent(Configurator.ATTACHMENT_KEY, result); if (existing != null) { result = existing; } } return result; }
private static void clearLogContext() { // Remove the configurator and clear the log context final Configurator configurator = EMBEDDED_LOG_CONTEXT.getLogger("").detach(Configurator.ATTACHMENT_KEY); // If this was a PropertyConfigurator we can use the LogContextConfiguration API to tear down the LogContext if (configurator instanceof PropertyConfigurator) { final LogContextConfiguration logContextConfiguration = ((PropertyConfigurator) configurator).getLogContextConfiguration(); clearLogContext(logContextConfiguration); } else if (configurator instanceof LogContextConfiguration) { clearLogContext((LogContextConfiguration) configurator); } else { // Remove all the handlers and close them as well as reset the loggers final List<String> loggerNames = Collections.list(EMBEDDED_LOG_CONTEXT.getLoggerNames()); for (String name : loggerNames) { final Logger logger = EMBEDDED_LOG_CONTEXT.getLoggerIfExists(name); if (logger != null) { final Handler[] handlers = logger.clearHandlers(); if (handlers != null) { for (Handler handler : handlers) { handler.close(); } } logger.setFilter(null); logger.setUseParentFilters(false); logger.setUseParentHandlers(true); logger.setLevel(Level.INFO); } } } }
public LogContextStdioContextSelector(final StdioContext defaultContext) { // Register the STDIO context on the default log context LogContext.getLogContext().getLogger(CommonAttributes.ROOT_LOGGER_NAME).attachIfAbsent(STDIO_CONTEXT_ATTACHMENT_KEY, defaultContext); }
if (LogContext.getSystemLogContext().getAttachment("", Configurator.ATTACHMENT_KEY) == null) { if (!"OFF".equalsIgnoreCase(logLevel)) { try { final Configurator appearing = LogContext.getSystemLogContext().getLogger("").attachIfAbsent(Configurator.ATTACHMENT_KEY, configurator); if (appearing == null) { configurator.configure(createLogManagerConfig(logLevel));
final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME); final ConfigurationPersistence result; synchronized (LOCK) { Configurator configurator = root.getAttachment(Configurator.ATTACHMENT_KEY); if (configurator == null) { configurator = new ConfigurationPersistence(logContext); Configurator existing = root.attachIfAbsent(Configurator.ATTACHMENT_KEY, configurator); if (existing != null) { configurator = existing; root.attach(Configurator.ATTACHMENT_KEY, result); } else {
public Logger getLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(name); final Logger logger = lmLogger.getAttachment(key); if (logger != null) { return logger; } return doPrivileged(new PrivilegedAction<Logger>() { public Logger run() { final Slf4jLogger newLogger = new Slf4jLogger(lmLogger); final Logger appearingLogger = lmLogger.attachIfAbsent(key, newLogger); return appearingLogger != null ? appearingLogger : newLogger; } }); } }
Configurator configurator = embeddedLogContext.getAttachment("", Configurator.ATTACHMENT_KEY); if (configurator == null) { configurator = new PropertyConfigurator(embeddedLogContext); final Configurator existing = embeddedLogContext.getLogger("").attachIfAbsent(Configurator.ATTACHMENT_KEY, configurator); if (existing != null) { configurator = existing;
@Override public Hierarchy run() { final LogContext lc = logContext == null ? LogContext.getLogContext() : logContext; final org.jboss.logmanager.Logger jbossRoot = getJBossLogger(lc, JBL_ROOT_NAME); Hierarchy hierarchy = jbossRoot.getAttachment(HIERARCHY_KEY); if (hierarchy == null) { // Always attach the root logger Logger root = jbossRoot.getAttachment(LOGGER_KEY); if (root == null) { root = new RootLogger(JBossLevelMapping.getPriorityFor(jbossRoot.getLevel())); final Logger appearing = jbossRoot.attachIfAbsent(LOGGER_KEY, root); if (appearing != null) { root = appearing; } } hierarchy = new Hierarchy(root); final Hierarchy appearing = jbossRoot.attachIfAbsent(HIERARCHY_KEY, hierarchy); if (appearing != null) { hierarchy = appearing; } } return hierarchy; } });
@Override public LogContext run() { return LogContext.getLogContext(); } };
/** * Get or create a logger with the given name. * * @param name the logger name * @return the corresponding logger */ public Logger getLogger(String name) { return LogContext.getLogContext().getLogger(name); }
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader()); LogContextConfiguration logContextConfiguration = null; final LogContext logContext = LogContext.getLogContext(); final Configurator configurator = logContext.getAttachment(CommonAttributes.ROOT_LOGGER_NAME, Configurator.ATTACHMENT_KEY); if (configurator instanceof LogContextConfiguration) { logContextConfiguration = (LogContextConfiguration) configurator;
/** * Gets the property configurator. If the {@link ConfigurationPersistence} does not exist a {@code null} is * returned. * * @param logContext the log context used to find the property configurator or to attach it to. * * @return the property configurator or {@code null} */ public static ConfigurationPersistence getConfigurationPersistence(final LogContext logContext) { if (logContext == null) return null; return (ConfigurationPersistence) logContext.getAttachment(CommonAttributes.ROOT_LOGGER_NAME, Configurator.ATTACHMENT_KEY); }
@Override public Enumeration<String> getLoggerNames() { return LogContext.getLogContext().getLoggerNames(); }
public Logger validate() throws IllegalArgumentException { return logContext.getLogger(loggerName); }
public Logger exists(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLoggerIfExists(name); if (lmLogger == null) { return null; } return create(lmLogger); }
LogContext.getSystemLogContext().getLogger("").attach(Configurator.ATTACHMENT_KEY, configurator); } catch (Throwable t) { StandardOutputStreams.printError(t, "Failed to read or configure the org.jboss.logmanager.LogManager");
return new SimpleObjectProducer(LogContext.getSystemLogContext().getLevelForName(trimmedValue)); } else if (paramType == java.util.logging.Logger.class) { return new SimpleObjectProducer(LogContext.getSystemLogContext().getLogger(trimmedValue)); } else if (paramType == boolean.class || paramType == Boolean.class) { return new SimpleObjectProducer(Boolean.valueOf(trimmedValue));
final LogContext logContext = parentLogger.getLogContext(); final String name = cat.getName(); int length = name.length(); final org.jboss.logmanager.Logger lmLogger = logContext.getLoggerIfExists(loggerName); final LoggerNode loggerNode = lmLogger.getAttachment(LOGGER_NODE_KEY); if (loggerNode == null) { final LoggerNode appearing = attachIfAbsent(lmLogger, LOGGER_NODE_KEY, new LoggerNode(cat));