Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
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)
log4cxx::LogManager::shutdown();
return 0;
}
—
###############################
#
- 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
|%-7p|%X
{Number}|%-3.3t| %m (%c)%n
#log4j.appender.CON.threshold=WARNING#XLevel