Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-577

Refactor LoggerContext initialization/destruction code

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.0-rc1
    • None
    • Configurators, Core
    • Standard JRE, servlet context, and extensible for other containers like OSGi

    Description

      Currently, the code for initialization is a bit scattered due to the servlet context initialization being added far later than the core stuff. The LoggerContext initialization code needs to be refactored to allow drop-in implementations based on the usage context. For example, the default init/destroy path is based in the LoggerContextFactory a shutdown hook thread to stop it. The web context uses a ServletContextListener (or more specifically, the web initialization class) to construct and destroy the LoggerContext. An OSGi bundle might wish to use a BundleActivator to start and stop the LoggerContext. There may be other usage scenarios not covered such as in an EJB, etc.

      The code for selecting a context is already modular in this way via the ContextSelector interface. I'd like to see something similar for the starting and stopping of a LoggerContext. See, for example, how it's done in logback (or slf4j if that's where it's implemented) or other logging frameworks (if any alternatives really exist).

      Attachments

        Issue Links

          Activity

            People

              mattsicker Matt Sicker
              mattsicker Matt Sicker
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: