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

Hierarchy corrupts with PropertyConfigurator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.10.0
    • 0.10.0
    • None
    • 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

      Attachments

        1. hierarchy.cpp.diff
          0.6 kB
          Kriz

        Activity

          People

            carnold@apache.org Curt Arnold
            chris75vie Kriz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: