Package ch.qos.logback.classic

Examples of ch.qos.logback.classic.LoggerContext.reset()


    try {
      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(context);
      // Call context.reset() to clear any previous configuration, e.g. default
      // configuration. For multi-step configuration, omit calling context.reset().
      context.reset();
      configurator.doConfigure(args[0]);
    } catch (JoranException je) {
      // StatusPrinter will handle this
    }
    StatusPrinter.printInCaseOfErrorsOrWarnings(context);
View Full Code Here


    if (configFile.endsWith(".xml")) {
      try {
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(lc);
        lc.reset();
        configurator.doConfigure(args[0]);
      } catch (JoranException je) {
        je.printStackTrace();
      }
    }
View Full Code Here

*/
public class LogbackOnConsole {

  public static void main(String[] args) {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    loggerContext.reset(); // optionally forget previous configuration

    PatternLayoutEncoder patternLayoutEncoder = new PatternLayoutEncoder();
    patternLayoutEncoder.setPattern("%-4relative [%thread] %-5level %logger{35} - %msg %n");
    patternLayoutEncoder.setContext(loggerContext);
    patternLayoutEncoder.start();
View Full Code Here

  static void programmaticConfiguration() {
    // Configure logback
    LoggerContext loggerContext = (LoggerContext) LoggerFactory
        .getILoggerFactory();
    loggerContext.reset();
    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setContext(loggerContext);
    layout.setPattern("%X{first} %X{last} - %m%n");
    layout.start();
    ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
View Full Code Here

  static void configureViaXML_File() {
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    try {
      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(lc);
      lc.reset();
      URL url = Loader.getResourceBySelfClassLoader("chapters/mdc/simpleMDC.xml");
      configurator.doConfigure(url);
    } catch (JoranException je) {
      StatusPrinter.print(lc);
    }
View Full Code Here

    String configFile = args[0];

    if (configFile.endsWith(".xml")) {
      LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
      lc.reset();
      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(lc);
      configurator.doConfigure(configFile);
    }
View Full Code Here

    String configFile = args[0];

    if (configFile.endsWith(".xml")) {
      LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
      lc.reset();
      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(lc);
      configurator.doConfigure(configFile);
    }
View Full Code Here

    public void run() {
      LoggerContext lc = (LoggerContext) context;

      if (fileToScan.toString().endsWith("groovy")) {
        if (EnvUtil.isGroovyAvailable()) {
          lc.reset();
          // avoid directly referring to GafferConfigurator so as to avoid
          // loading  groovy.lang.GroovyObject . See also http://jira.qos.ch/browse/LBCLASSIC-214
          GafferUtil.runGafferConfiguratorOn(lc, this, fileToScan);
        } else {
          addError("Groovy classes are not available on the class path. ABORTING INITIALIZATION.");
View Full Code Here

          addError("Groovy classes are not available on the class path. ABORTING INITIALIZATION.");
        }
      } else if (fileToScan.toString().endsWith("xml")) {
        JoranConfigurator jc = new JoranConfigurator();
        jc.setContext(context);
        lc.reset();
        try {
          jc.doConfigure(fileToScan);
          lc.getStatusManager().add(
                  new InfoStatus("done resetting the logging context", this));
        } catch (JoranException e) {
View Full Code Here

            // 初始化Logback
            LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(lc);
            lc.reset();
            configurator.doConfigure(brokerConfig.getRocketmqHome() + "/conf/logback_broker.xml");
            final Logger log = LoggerFactory.getLogger(LoggerName.BrokerLoggerName);

            // 打印启动参数
            MixAll.printObjectProperties(log, brokerConfig);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.