Java Code Examples for org.jboss.logmanager.LogContext#getLogger()

The following examples show how to use org.jboss.logmanager.LogContext#getLogger() . 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: LoggingConfigurationFileReloader.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private LoggingConfigurationUpdater getOrCreateUpdater() {
   final LogContext logContext = LogContext.getLogContext();
   final org.jboss.logmanager.Logger rootLogger = logContext.getLogger("");
   LoggingConfigurationUpdater updater = rootLogger.getAttachment(KEY);
   if (updater == null) {
      final LogContextConfiguration logContextConfiguration = getOrCreateConfiguration(rootLogger);
      if (logContextConfiguration == null) {
         return null;
      }
      updater = new LoggingConfigurationUpdater(logContextConfiguration);
      final LoggingConfigurationUpdater appearing = rootLogger.attachIfAbsent(KEY, updater);
      if (appearing != null) {
         updater = appearing;
      }
   }
   return updater;
}
 
Example 2
Source File: LogContextStdioContextSelector.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public StdioContext getStdioContext() {
    final LogContext logContext = LogContext.getLogContext();
    final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME);
    StdioContext stdioContext = root.getAttachment(STDIO_CONTEXT_ATTACHMENT_KEY);
    if (stdioContext == null) {
        stdioContext = StdioContext.create(
                new NullInputStream(),
                new LoggingOutputStream(logContext.getLogger("stdout"), Level.INFO),
                new LoggingOutputStream(logContext.getLogger("stderr"), Level.ERROR)
        );
        final StdioContext appearing = root.attachIfAbsent(STDIO_CONTEXT_ATTACHMENT_KEY, stdioContext);
        if (appearing != null) {
            stdioContext = appearing;
        }
    }
    return stdioContext;
}
 
Example 3
Source File: ConfigurationPersistence.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 4
Source File: LoggingOperationsSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Logger getLogger(final String profileName) {
    final LogContext logContext;
    if (profileName != null) {
        logContext = LoggingProfileContextSelector.getInstance().get(profileName);
    } else {
        logContext = LogContext.getSystemLogContext();
    }
    return logContext.getLogger(FQCN);
}