org.apache.logging.log4j.core.Appender.stop()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(137)

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

Appender.stop介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-druid

  1. @AfterClass
  2. public static void tearDownStatic()
  3. {
  4. final Logger logger = (Logger) LogManager.getLogger(
  5. LoggingRequestLogger.class);
  6. logger.removeAppender(appender);
  7. appender.stop();
  8. }

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

  1. void removeAndStopAppenders() {
  2. final Map<String, Appender> map = logger.getAppenders();
  3. for (final Map.Entry<String, Appender> entry : map.entrySet()) {
  4. final Appender appender = entry.getValue();
  5. logger.removeAppender(appender);
  6. appender.stop();
  7. }
  8. }

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

  1. protected void removeAppenders() {
  2. final Map<String,Appender> map = root.getAppenders();
  3. for (final Map.Entry<String, Appender> entry : map.entrySet()) {
  4. final Appender app = entry.getValue();
  5. root.removeAppender(app);
  6. app.stop();
  7. }
  8. }

代码示例来源:origin: igniterealtime/Openfire

  1. void removeAppender(final String name) {
  2. final LoggerContext context = LoggerContext.getContext(false);
  3. final Configuration config = context.getConfiguration();
  4. config.getAppenders().remove( name ).stop();
  5. for (final LoggerConfig loggerConfig : config.getLoggers().values()) {
  6. loggerConfig.removeAppender( name );
  7. }
  8. config.getRootLogger().removeAppender( name );
  9. }

代码示例来源:origin: apache/hive

  1. if (appenderControl.get() != null) {
  2. appenderControl.get().stop();
  3. realAppender.get().stop();

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

  1. @Test(timeout = 2000)
  2. public void testClose() throws Exception {
  3. final Appender appender = ctx.getRequiredAppender("KafkaAppender");
  4. appender.stop();
  5. }
  6. }

代码示例来源:origin: javamelody/javamelody

  1. void deregister() {
  2. if (LogManager.getContext(false) instanceof LoggerContext) {
  3. final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
  4. if (ctx.getConfiguration() instanceof AbstractConfiguration) {
  5. final AbstractConfiguration config = (AbstractConfiguration) ctx.getConfiguration();
  6. final Appender appender = getSingleton();
  7. appender.stop();
  8. config.removeAppender(appender.getName());
  9. final Logger rootLogger = LogManager.getRootLogger();
  10. final LoggerConfig loggerConfig = config.getLoggerConfig(rootLogger.getName());
  11. loggerConfig.removeAppender(appender.getName());
  12. ctx.updateLoggers();
  13. }
  14. }
  15. }

代码示例来源:origin: ops4j/org.ops4j.pax.logging

  1. /**
  2. * Deletes the specified appender.
  3. *
  4. * @param key The appender's key
  5. */
  6. public void deleteAppender(final String key) {
  7. LOGGER.debug("Deleting route with " + key + " key ");
  8. final AppenderControl control = appenders.remove(key);
  9. if (null != control) {
  10. LOGGER.debug("Stopping route with " + key + " key");
  11. control.getAppender().stop();
  12. } else {
  13. LOGGER.debug("Route with " + key + " key already deleted");
  14. }
  15. }

代码示例来源:origin: ops4j/org.ops4j.pax.logging

  1. /**
  2. * Remove an Appender. First removes any associations between LoggerConfigs and the Appender, removes the Appender
  3. * from this appender list and then stops the appender. This method is synchronized in case an Appender with the
  4. * same name is being added during the removal.
  5. *
  6. * @param appenderName the name of the appender to remove.
  7. */
  8. public synchronized void removeAppender(final String appenderName) {
  9. for (final LoggerConfig logger : loggerConfigs.values()) {
  10. logger.removeAppender(appenderName);
  11. }
  12. final Appender app = appenders.remove(appenderName);
  13. if (app != null) {
  14. app.stop();
  15. }
  16. }

代码示例来源:origin: org.infinispan/infinispan-commons-test

  1. /**
  2. * Delete the oldest appenders (sorted by their last access time) until there are maxSize appenders or less.
  3. */
  4. @Override
  5. public void purge() {
  6. synchronized (this) {
  7. Iterator<String> iterator = appendersUsage.keySet().iterator();
  8. while (appendersUsage.size() > maxSize) {
  9. String key = iterator.next();
  10. LOGGER.debug("Removing appender " + key);
  11. iterator.remove();
  12. routingAppender.getAppenders().get(key).getAppender().stop();
  13. routingAppender.deleteAppender(key);
  14. }
  15. }
  16. }

代码示例来源:origin: elastic/support-diagnostics

  1. public static void cleanup(String dir) {
  2. try {
  3. LoggerContext lc = (LoggerContext) LogManager.getContext(false);
  4. final Configuration config = lc.getConfiguration();
  5. Appender appndr = config.getAppender("File");
  6. appndr.stop();
  7. config.getRootLogger().removeAppender("File");
  8. File tempdir = new File(dir);
  9. tempdir.setWritable(true, false);
  10. FileUtils.deleteDirectory(tempdir);
  11. logger.info("Temp directory {} was deleted.", dir);
  12. } catch (IOException e) {
  13. String msg = "Error deleting temporary work directory";
  14. logger.error(msg, e);
  15. }
  16. logger.info("Cleanup complete.");
  17. }

代码示例来源:origin: org.apache.logging.log4j/log4j-flume-ng

  1. private void removeAppenders(final Logger logger) {
  2. final Map<String, Appender> map = logger.getAppenders();
  3. for (final Map.Entry<String, Appender> entry : map.entrySet()) {
  4. final Appender app = entry.getValue();
  5. avroLogger.removeAppender(app);
  6. app.stop();
  7. }
  8. }

代码示例来源:origin: org.apache.hive/hive-llap-server

  1. if (appenderControl.get() != null) {
  2. appenderControl.get().stop();
  3. realAppender.get().stop();

代码示例来源:origin: ops4j/org.ops4j.pax.logging

  1. @Override
  2. public boolean stop(final long timeout, final TimeUnit timeUnit) {
  3. setStopping();
  4. super.stop(timeout, timeUnit, false);
  5. final Map<String, Appender> map = configuration.getAppenders();
  6. for (final Map.Entry<String, AppenderControl> entry : appenders.entrySet()) {
  7. final Appender appender = entry.getValue().getAppender();
  8. if (!map.containsKey(appender.getName())) {
  9. if (appender instanceof LifeCycle2) {
  10. ((LifeCycle2) appender).stop(timeout, timeUnit);
  11. } else {
  12. appender.stop();
  13. }
  14. }
  15. }
  16. setStopped();
  17. return true;
  18. }

代码示例来源:origin: ops4j/org.ops4j.pax.logging

  1. ((LifeCycle2) appender).stop(timeout, timeUnit);
  2. } else {
  3. appender.stop();
  4. ((LifeCycle2) array[i]).stop(timeout, timeUnit);
  5. } else {
  6. array[i].stop();

代码示例来源:origin: info.magnolia/magnolia-core

  1. /**
  2. * Removes the given appender from the root logger; typically upon tear-down (@After).
  3. */
  4. public static void stopRecordingLogs(Appender appender) {
  5. LoggerContext context = LoggerContext.getContext(false);
  6. Configuration config = context.getConfiguration();
  7. String appenderName = appender.getName();
  8. if (config.getAppenders().remove(appenderName) != null) {
  9. appender.stop();
  10. config.getRootLogger().removeAppender(appenderName);
  11. context.updateLoggers(config);
  12. }
  13. }
  14. }

代码示例来源:origin: net.bull.javamelody/javamelody-core

  1. void deregister() {
  2. if (LogManager.getContext(false) instanceof LoggerContext) {
  3. final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
  4. if (ctx.getConfiguration() instanceof AbstractConfiguration) {
  5. final AbstractConfiguration config = (AbstractConfiguration) ctx.getConfiguration();
  6. final Appender appender = getSingleton();
  7. appender.stop();
  8. config.removeAppender(appender.getName());
  9. final Logger rootLogger = LogManager.getRootLogger();
  10. final LoggerConfig loggerConfig = config.getLoggerConfig(rootLogger.getName());
  11. loggerConfig.removeAppender(appender.getName());
  12. ctx.updateLoggers();
  13. }
  14. }
  15. }

相关文章