Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-560

Logging in a static initializer

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.0.0
    • None
    • None

    Description

      Logging needs to be configured before the first log call. To log in a static initializer code, configuration must be executed during static initialization.

      The log4cxx documentation and examples suggest calling the configure method of the selected configurator in the main routine. It does not currently describe automatic configuration. 

      Automatic configuration currently requires either a special name (log4cxx.xxx or log4j.xxx) for the config file or an environment variable (LOG4CXX_CONFIGURATION or log4j.configuration) set with the name of the config file.

      It would be nice to be able to plug in user specified configuration logic that is invoked by log4cxx.

      One possible approach would be to override autoConfigure() (added in #135) in a class that inherits from log4cxx::Hierarchy.

      Calling the LogManager::setRepositorySelector static function before other static initialisations is difficult as static initialization order is not easily controlled.

      A new static method LogManager::getLogger("name", MyRepository::Instance()) would prevent static initialization order issues.

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              swebb2066 Stephen Webb
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: