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

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

本文整理了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

  1. public void applyPostCreate(final Void param) {
  2. if (refLogger != null) {
  3. refLogger.setFilter(null);
  4. refLogger.clearHandlers();
  5. refLogger.setLevel(null);
  6. refLogger.setUseParentHandlers(true);
  7. }
  8. }

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

  1. /**
  2. * Start method; removes and saves bootstrap handlers.
  3. */
  4. public void start() {
  5. log.info("Removing bootstrap log handlers");
  6. final Handler[] bootstrapHandlers = rootLogger.clearHandlers();
  7. this.bootstrapHandlers = bootstrapHandlers;
  8. for (Handler handler : bootstrapHandlers) {
  9. safeFlush(handler);
  10. }
  11. // this message probably won't appear anywhere...
  12. log.info("Removed bootstrap log handlers");
  13. }

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

  1. /**
  2. * Stop method; removes root handlers and restores the bootstrap handlers.
  3. */
  4. public void stop() {
  5. // this message probably won't appear anywhere...
  6. log.info("Restoring bootstrap log handlers");
  7. // clear any remaining handlers from the root (there shouldn't be any, but...)
  8. for (Handler handler : rootLogger.clearHandlers()) {
  9. safeClose(handler);
  10. }
  11. final Handler[] bootstrapHandlers = this.bootstrapHandlers;
  12. this.bootstrapHandlers = null;
  13. for (Handler handler : bootstrapHandlers) {
  14. rootLogger.addHandler(handler);
  15. }
  16. log.info("Restored bootstrap log handlers");
  17. }

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

  1. private static void clearLogContext() {
  2. // Remove the configurator and clear the log context
  3. final Configurator configurator = EMBEDDED_LOG_CONTEXT.getLogger("").detach(Configurator.ATTACHMENT_KEY);
  4. // If this was a PropertyConfigurator we can use the LogContextConfiguration API to tear down the LogContext
  5. if (configurator instanceof PropertyConfigurator) {
  6. final LogContextConfiguration logContextConfiguration = ((PropertyConfigurator) configurator).getLogContextConfiguration();
  7. clearLogContext(logContextConfiguration);
  8. } else if (configurator instanceof LogContextConfiguration) {
  9. clearLogContext((LogContextConfiguration) configurator);
  10. } else {
  11. // Remove all the handlers and close them as well as reset the loggers
  12. final List<String> loggerNames = Collections.list(EMBEDDED_LOG_CONTEXT.getLoggerNames());
  13. for (String name : loggerNames) {
  14. final Logger logger = EMBEDDED_LOG_CONTEXT.getLoggerIfExists(name);
  15. if (logger != null) {
  16. final Handler[] handlers = logger.clearHandlers();
  17. if (handlers != null) {
  18. for (Handler handler : handlers) {
  19. handler.close();
  20. }
  21. }
  22. logger.setFilter(null);
  23. logger.setUseParentFilters(false);
  24. logger.setUseParentHandlers(true);
  25. logger.setLevel(Level.INFO);
  26. }
  27. }
  28. }
  29. }

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

  1. private static void clearLogContext() {
  2. // Remove the configurator and clear the log context
  3. final Configurator configurator = EMBEDDED_LOG_CONTEXT.getLogger("").detach(Configurator.ATTACHMENT_KEY);
  4. // If this was a PropertyConfigurator we can use the LogContextConfiguration API to tear down the LogContext
  5. if (configurator instanceof PropertyConfigurator) {
  6. final LogContextConfiguration logContextConfiguration = ((PropertyConfigurator) configurator).getLogContextConfiguration();
  7. clearLogContext(logContextConfiguration);
  8. } else if (configurator instanceof LogContextConfiguration) {
  9. clearLogContext((LogContextConfiguration) configurator);
  10. } else {
  11. // Remove all the handlers and close them as well as reset the loggers
  12. final List<String> loggerNames = Collections.list(EMBEDDED_LOG_CONTEXT.getLoggerNames());
  13. for (String name : loggerNames) {
  14. final Logger logger = EMBEDDED_LOG_CONTEXT.getLoggerIfExists(name);
  15. if (logger != null) {
  16. final Handler[] handlers = logger.clearHandlers();
  17. if (handlers != null) {
  18. for (Handler handler : handlers) {
  19. handler.close();
  20. }
  21. }
  22. logger.setFilter(null);
  23. logger.setUseParentFilters(false);
  24. logger.setUseParentHandlers(true);
  25. logger.setLevel(Level.INFO);
  26. }
  27. }
  28. }
  29. }

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

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

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

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

相关文章