Package ch.qos.logback.classic.joran

Examples of ch.qos.logback.classic.joran.JoranConfigurator


        String rocketmqHome =
                System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));

        // 初始化Logback
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(lc);
        lc.reset();
        configurator.doConfigure(rocketmqHome + "/conf/logback_tools.xml");
    }
View Full Code Here


        }
      }
    }

    private void performXMLConfiguration(LoggerContext lc) {
      JoranConfigurator jc = new JoranConfigurator();
      jc.setContext(context);
      StatusChecker statusChecker = new StatusChecker(context);
      List<SaxEvent> eventList = jc.recallSafeConfiguration();
      URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(context);
      lc.reset();
      long threshold = System.currentTimeMillis();
      try {
        jc.doConfigure(mainConfigurationURL);
        if (statusChecker.hasXMLParsingErrors(threshold)) {
          fallbackConfiguration(lc, eventList, mainURL);
        }
      } catch (JoranException e) {
        fallbackConfiguration(lc, eventList, mainURL);
View Full Code Here

        fallbackConfiguration(lc, eventList, mainURL);
      }
    }

    private void fallbackConfiguration(LoggerContext lc, List<SaxEvent> eventList, URL mainURL) {
      JoranConfigurator joranConfigurator = new JoranConfigurator();
      joranConfigurator.setContext(context);
      if (eventList != null) {
        addWarn("Falling back to previously registered safe configuration.");
        try {
          lc.reset();
          joranConfigurator.informContextOfURLUsedForConfiguration(context, mainURL);
          joranConfigurator.doConfigure(eventList);
          addInfo("Re-registering previous fallback configuration once more as a fallback configuration point");
          joranConfigurator.registerSafeConfiguration();
        } catch (JoranException e) {
          addError("Unexpected exception thrown by a configuration considered safe.", e);
        }
      } else {
        addWarn("No previous configuration to fall back to.");
View Full Code Here

        list = (StringListAppender<ILoggingEvent>) rootLogger.getAppender("LIST");
        rootLogger.detachAppender("console");
    }

    private static void configure(final String file) throws JoranException {
        final JoranConfigurator jc = new JoranConfigurator();
        jc.setContext(context);
        jc.doConfigure(file);
    }
View Full Code Here

    }
  }

  static public void configureLC(LoggerContext lc, String configFile)
      throws JoranException {
    JoranConfigurator configurator = new JoranConfigurator();
    lc.reset();
    configurator.setContext(lc);
    configurator.doConfigure(configFile);
  }
View Full Code Here

  private void configureLoggerContextByResource(LoggerContext context,
      String configFilePath) {
    URL url = Loader.getResourceByTCL(configFilePath);
    if (url != null) {
      try {
        JoranConfigurator configurator = new JoranConfigurator();
        context.shutdownAndReset();
        configurator.setContext(context);
        configurator.doConfigure(url);
      } catch (JoranException e) {
        StatusPrinter.print(context);
      }
    } else {
      Logger logger = defaultContext.getLogger(LoggerContext.ROOT_NAME);
View Full Code Here

        StatusManager sm = loggerContext.getStatusManager();
        sm.add(new ErrorStatus("Groovy classes are not available on the class path. ABORTING INITIALIZATION.",
                loggerContext));
      }
    } else if (url.toString().endsWith("xml")) {
      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(loggerContext);
      configurator.doConfigure(url);
    } else {
      throw new LogbackException("Unexpected filename extension of file [" + url.toString() + "]. Should be either .groovy or .xml");
    }
  }
View Full Code Here

      throw new LogbackException("Unexpected filename extension of file [" + url.toString() + "]. Should be either .groovy or .xml");
    }
  }

  void joranConfigureByResource(URL url) throws JoranException {
    JoranConfigurator configurator = new JoranConfigurator();
    configurator.setContext(loggerContext);
    configurator.doConfigure(url);
  }
View Full Code Here

    loggerContext.reset();
    // after a reset the statusListenerAsList gets removed as a listener
    addStatusListener(statusListenerAsList);

    try {
      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(loggerContext);
      configurator.doConfigure(url);
      addInfo("Context: " + loggerContext.getName() + " reloaded.");
    } finally {
      removeStatusListener(statusListenerAsList);
      if (debug) {
        StatusPrinter.print(statusListenerAsList.getStatusList());
View Full Code Here

        }
      }
    }

    private void performXMLConfiguration(LoggerContext lc) {
      JoranConfigurator jc = new JoranConfigurator();
      jc.setContext(context);
      StatusUtil statusUtil = new StatusUtil(context);
      List<SaxEvent> eventList = jc.recallSafeConfiguration();
      URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(context);
      lc.reset();
      long threshold = System.currentTimeMillis();
      try {
        jc.doConfigure(mainConfigurationURL);
        if (statusUtil.hasXMLParsingErrors(threshold)) {
          fallbackConfiguration(lc, eventList, mainURL);
        }
      } catch (JoranException e) {
        fallbackConfiguration(lc, eventList, mainURL);
View Full Code Here

TOP

Related Classes of ch.qos.logback.classic.joran.JoranConfigurator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.