Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-284

Support loading configuration via classpath

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • logback-core
    • None

    Description

      A lot of boilerplate is needed to load a configuration file with Joran. I suggest improving doConfigure to support scanning inputs on the classpath. Sample code of 7 lines could be condensed to two.

      LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(context);
      context.reset();

      InputStream inputStream = SmtpTest.class.getClassLoader().getResourceAsStream(INPUT_FILE);
      if(inputStream == null) throw new IllegalStateException("File not found: " + INPUT_FILE);
      configurator.doConfigure(inputStream);

      VS

      JoranConfigurator configurator = new JoranConfigurator();
      configurator.doConfigure(INPUT_FILE);

      Attachments

        Activity

          People

            logback-dev Logback dev list
            dcompiled Alex Glass
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: