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

Facade method for configuration by xml: Programmatic configuration should be a single line

    XMLWordPrintable

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.0.0
    • logback-classic
    • None

    Description

      From a user's perspective, it doesn't a bit overkill to copy paste all this stuff:

          LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
          
          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(getClass.getResource("/com/domain/project/logback.xml"));
          } catch (JoranException je) {
            // StatusPrinter will handle this
          }
          StatusPrinter.printInCaseOfErrorsOrWarnings(context);
      

      It would be nicer if we had a simple static facade method, on JoranConfigurator or LoggerContext, that does all that stuff:

      JoranConfigurator.configure(getClass.getResource("/com/domain/project/logback.xml"));
      

      We shouldn't need to understand the internals and the lifecycle of the JoranConfigurator.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            ge0ffrey Geoffrey De Smet
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: