org.jboss.logmanager.PropertyConfigurator Java Examples
The following examples show how to use
org.jboss.logmanager.PropertyConfigurator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BootableJar.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private LogContext configureLogContext() throws IOException { final Path baseDir = jbossHome.resolve(STANDALONE); String serverLogDir = System.getProperty(JBOSS_SERVER_LOG_DIR, null); if (serverLogDir == null) { serverLogDir = baseDir.resolve(LOG).toString(); System.setProperty(JBOSS_SERVER_LOG_DIR, serverLogDir); } final String serverCfgDir = System.getProperty(JBOSS_SERVER_CONFIG_DIR, baseDir.resolve(CONFIGURATION).toString()); final LogContext embeddedLogContext = LogContext.create(); final Path bootLog = Paths.get(serverLogDir).resolve(SERVER_LOG); final Path loggingProperties = Paths.get(serverCfgDir).resolve(Paths.get(LOGGING_PROPERTIES)); if (Files.exists(loggingProperties)) { try (final InputStream in = Files.newInputStream(loggingProperties)) { System.setProperty(LOG_BOOT_FILE_PROP, bootLog.toAbsolutePath().toString()); PropertyConfigurator configurator = new PropertyConfigurator(embeddedLogContext); configurator.configure(in); } } return embeddedLogContext; }
Example #2
Source File: ConfigurationPersistence.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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); 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; } } if (configurator instanceof ConfigurationPersistence) { // We have the correct configurator result = (ConfigurationPersistence) configurator; } else if (configurator instanceof PropertyConfigurator) { // Create a new configurator delegating to the configurator found result = new ConfigurationPersistence((PropertyConfigurator) configurator); root.attach(Configurator.ATTACHMENT_KEY, result); } else { // An unknown configurator, log a warning and replace LoggingLogger.ROOT_LOGGER.replacingConfigurator(configurator); result = new ConfigurationPersistence(logContext); root.attach(Configurator.ATTACHMENT_KEY, result); } } return result; }
Example #3
Source File: WildFlyLogContextSelector.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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); } } } }
Example #4
Source File: AbstractLoggingSubsystemTest.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@SuppressWarnings("ChainOfInstanceofChecks") private LogContextConfiguration getLogContextConfiguration(final LogContext logContext) { final Configurator configurator = logContext.getAttachment(CommonAttributes.ROOT_LOGGER_NAME, Configurator.ATTACHMENT_KEY); if (configurator instanceof LogContextConfiguration) { return (LogContextConfiguration) configurator; } if (configurator instanceof PropertyConfigurator) { return ((PropertyConfigurator) configurator).getLogContextConfiguration(); } return null; }
Example #5
Source File: EmbeddedLogContext.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Attempts to clear the global log context used for embedded servers. */ static synchronized void clearLogContext() { final LogContext embeddedLogContext = Holder.LOG_CONTEXT; // Remove the configurator and clear the log context final Configurator configurator = embeddedLogContext.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(embeddedLogContext.getLoggerNames()); for (String name : loggerNames) { final Logger logger = embeddedLogContext.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); } } } }
Example #6
Source File: ConfigurationPersistence.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private ConfigurationPersistence(final LogContext logContext) { this(new PropertyConfigurator(logContext)); }
Example #7
Source File: ConfigurationPersistence.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private ConfigurationPersistence(final PropertyConfigurator config) { this.config = config; delegate = config.getLogContextConfiguration(); }
Example #8
Source File: LoggingConfigurator.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 2 votes |
/** * Construct a new instance. * * @param context the log context to be configured */ public LoggingConfigurator(LogContext context) { this.context = context; this.propertyConfigurator = new PropertyConfigurator(this.context); }