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

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

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

Logger.setLevel介绍

[英]This implementation grabs a lock, so that only one thread may update the log level of any logger at a time, in order to allow readers to never block (though there is a window where retrieving the log level reflects an older effective level than the actual level).
[中]此实现获取一个锁,以便一次只有一个线程可以更新任何记录器的日志级别,以允许读卡器从不阻塞(尽管存在一个窗口,其中检索日志级别反映的有效级别比实际级别旧)。

代码示例

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

  1. @Override
  2. public void setThreshold(Level l) {
  3. if (l != null) {
  4. jblmRootLogger.setLevel(JBossLevelMapping.getLevelFor(l));
  5. }
  6. }

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

  1. public void setLevel(Level level) {
  2. synchronized (LEVEL_LOCK) {
  3. jblmLogger.setLevel(JBossLevelMapping.getLevelFor(level));
  4. this.level = level;
  5. }
  6. }

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

  1. @Override
  2. public Object run() {
  3. jblmLogger.setLevel(JBossLevelMapping.getLevelFor(level));
  4. return null;
  5. }
  6. });

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

  1. @Deprecated
  2. public void setPriority(final Priority priority) {
  3. logger.setLevel(LevelMapping.getLevelFor(priority));
  4. }

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

  1. public void applyPostCreate(final Level param) {
  2. configuration.getLoggerRefs().get(getName()).setLevel(param);
  3. }

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

  1. /**
  2. * Set the log level by name. Uses the parent logging context's name registry; otherwise behaves
  3. * identically to {@link #setLevel(Level)}.
  4. *
  5. * @param newLevelName the name of the level to set
  6. * @throws SecurityException if a security manager exists and if the caller does not have LoggingPermission("control")
  7. */
  8. public void setLevelName(String newLevelName) throws SecurityException {
  9. setLevel(loggerNode.getContext().getLevelForName(newLevelName));
  10. }

代码示例来源: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. @SuppressWarnings({"unchecked"})
  2. public void rollback() {
  3. if (refLogger != null) {
  4. refLogger.setFilter(filter);
  5. if (handlers != null) refLogger.setHandlers(handlers);
  6. refLogger.setLevel(level);
  7. refLogger.setUseParentHandlers(useParentHandlers);
  8. configs.put(name, LoggerConfigurationImpl.this);
  9. }
  10. clearRemoved();
  11. }
  12. };

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

  1. public Hierarchy(Logger root) {
  2. listeners = new CopyOnWriteArraySet<HierarchyEventListener>();
  3. jblmRootLogger = JBossLogManagerFacade.getJBossLogger(JBossLogManagerFacade.JBL_ROOT_NAME);
  4. jblmRootLogger.setLevel(JBossLevelMapping.getLevelFor(root.getLevel()));
  5. defaultFactory = new DefaultCategoryFactory();
  6. rendererMap = new RendererMap();
  7. }

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

  1. public final Level getLevel() {
  2. synchronized (LEVEL_LOCK) {
  3. if (level != null) {
  4. // Check to see if the level was changed on the JBoss LogManger logger and set to match the current level
  5. final Level currentLevel = JBossLevelMapping.getPriorityFor(jblmLogger.getLevel());
  6. if (currentLevel.toInt() != level.toInt()) {
  7. // It's likely this shouldn't happen, but to be safe we should run in a privilege block
  8. if (System.getSecurityManager() == null) {
  9. jblmLogger.setLevel(JBossLevelMapping.getLevelFor(level));
  10. } else {
  11. AccessController.doPrivileged(new PrivilegedAction<Object>() {
  12. @Override
  13. public Object run() {
  14. jblmLogger.setLevel(JBossLevelMapping.getLevelFor(level));
  15. return null;
  16. }
  17. });
  18. }
  19. }
  20. }
  21. }
  22. return level;
  23. }

代码示例来源:origin: apache/activemq-artemis

  1. @Test
  2. public void testMultipleConcurrentDurableSubscribers() throws Exception {
  3. org.jboss.logmanager.Logger.getLogger(StompConnection.class.getName()).setLevel(org.jboss.logmanager.Level.TRACE);
  4. int NUMBER_OF_THREADS = 25;
  5. SubscriberThread[] threads = new SubscriberThread[NUMBER_OF_THREADS];
  6. final CountDownLatch startFlag = new CountDownLatch(1);
  7. final CountDownLatch alignFlag = new CountDownLatch(NUMBER_OF_THREADS);
  8. for (int i = 0; i < threads.length; i++) {
  9. threads[i] = new SubscriberThread("subscriber::" + i, StompClientConnectionFactory.createClientConnection(uri), startFlag, alignFlag);
  10. }
  11. for (SubscriberThread t : threads) {
  12. t.start();
  13. }
  14. alignFlag.await();
  15. startFlag.countDown();
  16. for (SubscriberThread t : threads) {
  17. t.join();
  18. Assert.assertEquals(0, t.errors.get());
  19. }
  20. }

代码示例来源:origin: apache/activemq-artemis

  1. @Test
  2. public void testMultipleDurableSubscribers() throws Exception {
  3. org.jboss.logmanager.Logger.getLogger(StompConnection.class.getName()).setLevel(org.jboss.logmanager.Level.TRACE);
  4. conn.connect(defUser, defPass, "myClientID");
  5. StompClientConnectionV12 conn2 = (StompClientConnectionV12) StompClientConnectionFactory.createClientConnection(uri);
  6. conn2.connect(defUser, defPass, "myClientID");
  7. subscribe(conn, UUID.randomUUID().toString(), "client-individual", getName());
  8. subscribe(conn2, UUID.randomUUID().toString(), "clientindividual", getName());
  9. conn.closeTransport();
  10. waitDisconnect(conn);
  11. conn2.closeTransport();
  12. waitDisconnect(conn2);
  13. }

代码示例来源: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-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: org.wildfly.core/wildfly-cli

  1. logger.setUseParentFilters(false);
  2. logger.setUseParentHandlers(true);
  3. logger.setLevel(Level.INFO);

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

  1. logger.setUseParentFilters(false);
  2. logger.setUseParentHandlers(true);
  3. logger.setLevel(Level.INFO);

代码示例来源:origin: apache/activemq-artemis

  1. @Test
  2. public void testBasicPluginAuthorization() throws Exception {
  3. org.jboss.logmanager.Logger.getLogger(LDAPLoginModule.class.getName()).setLevel(org.jboss.logmanager.Level.DEBUG);
  4. org.jboss.logmanager.Logger.getLogger(LegacyLDAPSecuritySettingPlugin.class.getName()).setLevel(org.jboss.logmanager.Level.DEBUG);
  5. server.start();
  6. ClientSessionFactory cf = locator.createSessionFactory();
  7. String name = "TEST.FOO";
  8. try {
  9. ClientSession session = cf.createSession("admin", "secret", false, true, true, false, 0);
  10. session.createQueue(SimpleString.toSimpleString(name), SimpleString.toSimpleString(name));
  11. ClientProducer producer = session.createProducer();
  12. producer.send(name, session.createMessage(false));
  13. session.close();
  14. } catch (ActiveMQException e) {
  15. e.printStackTrace();
  16. Assert.fail("should not throw exception");
  17. }
  18. cf.close();
  19. }
  20. }

相关文章