org.jboss.logmanager.Logger.clearHandlers()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.jboss.logmanager.Logger.clearHandlers()方法的一些代码示例,展示了Logger.clearHandlers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.clearHandlers()方法的具体详情如下:
包路径:org.jboss.logmanager.Logger
类名称:Logger
方法名:clearHandlers

Logger.clearHandlers介绍

[英]A convenience method to atomically get and clear all handlers.
[中]以原子方式获取和清除所有处理程序的方便方法。

代码示例

代码示例来源:origin: org.jboss.logmanager/jboss-logmanager

public void applyPostCreate(final Void param) {
  if (refLogger != null) {
    refLogger.setFilter(null);
    refLogger.clearHandlers();
    refLogger.setLevel(null);
    refLogger.setUseParentHandlers(true);
  }
}

代码示例来源:origin: org.jboss.logmanager/jboss-logmanager

/**
 * Start method; removes and saves bootstrap handlers.
 */
public void start() {
  log.info("Removing bootstrap log handlers");
  final Handler[] bootstrapHandlers = rootLogger.clearHandlers();
  this.bootstrapHandlers = bootstrapHandlers;
  for (Handler handler : bootstrapHandlers) {
    safeFlush(handler);
  }
  // this message probably won't appear anywhere...
  log.info("Removed bootstrap log handlers");
}

代码示例来源:origin: org.jboss.logmanager/jboss-logmanager

/**
 * Stop method; removes root handlers and restores the bootstrap handlers.
 */
public void stop() {
  // this message probably won't appear anywhere...
  log.info("Restoring bootstrap log handlers");
  // clear any remaining handlers from the root (there shouldn't be any, but...)
  for (Handler handler : rootLogger.clearHandlers()) {
    safeClose(handler);
  }
  final Handler[] bootstrapHandlers = this.bootstrapHandlers;
  this.bootstrapHandlers = null;
  for (Handler handler : bootstrapHandlers) {
    rootLogger.addHandler(handler);
  }
  log.info("Restored bootstrap log handlers");
}

代码示例来源:origin: org.wildfly.core/wildfly-logging

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);
      }
    }
  }
}

代码示例来源:origin: wildfly/wildfly-core

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);
      }
    }
  }
}

代码示例来源:origin: org.wildfly.core/wildfly-cli

final Logger logger = embeddedLogContext.getLoggerIfExists(name);
if (logger != null) {
  final Handler[] handlers = logger.clearHandlers();
  if (handlers != null) {
    for (Handler handler : handlers) {

代码示例来源:origin: wildfly/wildfly-core

final Logger logger = embeddedLogContext.getLoggerIfExists(name);
if (logger != null) {
  final Handler[] handlers = logger.clearHandlers();
  if (handlers != null) {
    for (Handler handler : handlers) {

相关文章