Log4cxx
  1. Log4cxx
  2. LOGCXX-118

Hierarchy corrupts with PropertyConfigurator

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.10.0
    • Component/s: None
    • Labels:
      None

      Description

      I've found out that if you use the log4cxx as attached in the sample code the hierarchy is not correct.
      There are 2 logger objects: "Comm.CommClient" and "Comm.CommServer" both are descendant of "root".
      After the configuration "Comm.CommClient" is correctly descendant of "Comm", but "Comm.CommServer" is still descendant of "root".

      // LogTest.cpp : Defines the entry point for the console application.
      //

      #include <log4cxx/Logger.h>
      #include <log4cxx/PropertyConfigurator.h>
      #include <log4cxx/LogManager.h>

      void print( log4cxx::LoggerPtr& logger )
      {
      log4cxx::LoggerPtr l=logger;

      for (l=logger;l;l=l->getParent())

      { printf("%s[%s]->",l->getName().c_str(),l->getLevel() ? l->getLevel()->toString().c_str() : "?" ); }

      printf("\n");
      }

      int main(int argc, char* argv[])
      {
      log4cxx::LoggerPtr Logger11 = log4cxx::Logger::getLogger( "Comm.CommClient" );
      log4cxx::LoggerPtr Logger12 = log4cxx::Logger::getLogger( "Comm.CommServer" );

      print( Logger11 );
      print( Logger12 );

      log4cxx::PropertyConfigurator::configureAndWatch( log4cxx::File( "\\dev
      LogTest.properties" ) );

      print( Logger11 );
      print( Logger12 );

      int i=0;
      while (++i<3)

      { Logger11->debug("test logging text"); Logger12->debug("test logging text"); }

      log4cxx::LogManager::shutdown();

      return 0;
      }

      ###############################
      #

      1. LogTest.properties
        #
        ###############################

      #log4j.debug=true

      log4j.rootLogger=ALL, CON

      log4j.logger.Comm=INFO

      log4j.appender.CON=ConsoleAppender
      log4j.appender.CON.layout=PatternLayout
      log4j.appender.CON.layout.ConversionPattern=%d

      {HH:mm:ss.SSS}

      |%-7p|%X

      {Number}

      |%-3.3t| %m (%c)%n
      #log4j.appender.CON.threshold=WARNING#XLevel

        Activity

        Hide
        Curt Arnold added a comment -

        Apparently ancient miscopying of log4j code. The effect of the bug was that any call to Logger::getLogger() with a new logger name would obliterate the entries used to update the parent member for siblings of the new logger. Added HierarchyTest::testGetParent that fails with the old code and succeeds with the new.

        Show
        Curt Arnold added a comment - Apparently ancient miscopying of log4j code. The effect of the bug was that any call to Logger::getLogger() with a new logger name would obliterate the entries used to update the parent member for siblings of the new logger. Added HierarchyTest::testGetParent that fails with the old code and succeeds with the new.

          People

          • Assignee:
            Curt Arnold
            Reporter:
            Kriz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development