public Logger exists(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLoggerIfExists(name); if (lmLogger == null) { return null; } return create(lmLogger); }
/** * Checks the log context for an attached logger. If the logger is found it is returned, otherwise {@code null} is * returned. * * @param name the name of the logger to check. * * @return the logger or {@code null} if the logger does not exist. */ static Logger exists(String name) { final org.jboss.logmanager.Logger logger = getLogContext().getLoggerIfExists(name); return logger == null ? null : getLogger(logger); }
/** * Returns a collection of the loggers that exist. * * @return a collection of the loggers. */ static Collection<Logger> getLoggers() { final LogContext logContext = getLogContext(); final List<String> loggerNames = logContext.getLoggingMXBean().getLoggerNames(); final List<Logger> currentLoggers = new ArrayList<Logger>(loggerNames.size()); for (String name : loggerNames) { final org.jboss.logmanager.Logger lmLogger = logContext.getLoggerIfExists(name); if (lmLogger != null) { final Logger logger = getLogger(lmLogger); if (logger != null) { currentLoggers.add(logger); } } } return currentLoggers; }
final org.jboss.logmanager.Logger lmLogger = logContext.getLoggerIfExists(loggerName);
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); } } } }
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); } } } }
final Logger logger = embeddedLogContext.getLoggerIfExists(name); if (logger != null) { final Handler[] handlers = logger.clearHandlers();
final Logger logger = embeddedLogContext.getLoggerIfExists(name); if (logger != null) { final Handler[] handlers = logger.clearHandlers();