Hey I'm trying the log4cplus (which is similar to log4j and therefore my tags) library.
From the property file, is it possible to make a loggers level depend on its parents like this:
- If parent=INFO & child=WARN , child should log messages >= "WARN"
- If parent=OFF & child=WARN , child shouldn't log any messages.
- If parent.parent=ALL & parent=WARN & child=INFO, child should log messages >=WARN
- If parent.parent=OFF & parent=ALL & child=WARN , no one should log messages cause parent.parent.
With my code below the result is following (and wrong!)
- parent=WARN & child=FATAL , child is logging WARN messages
- parent=OFF & child=WARN , child is logging messages.
my property file - log.properties:
log4cplus.logger.cpuLoad=WARN, FILEAPPENDER
log4cplus.logger.cpuLoad.child=FATAL, FILEAPPENDER
log4cplus.additivity.cpuLoad.child=false
log4cplus.appender.FILEAPPENDER=log4cplus::RollingFileAppender
log4cplus.appender.FILEAPPENDER.File=./cpuLoad.log
log4cplus.appender.FILEAPPENDER.MaxFileSize=1MB
log4cplus.appender.FILEAPPENDER.layout=log4cplus::PatternLayout
log4cplus.appender.FILEAPPENDER.layout.ConversionPattern=%d{%m/%d/%y %H:%M:%S} %-5p %c{2} – %m%n
My c++ code - main.cpp:
Logger loggerCpu = Logger::getInstance("cpuLoad");
Logger loggerCpuChild = Logger::getInstance("cpuLoad.child");
LOG4CPLUS_WARN(loggerCpu, "hello from loggerCpu");
LOG4CPLUS_WARN(loggerCpuChild, "hello from loggerCpuChild" );
I want this to work from the log4cplus library itself, and mostly from the property file. I also need this parent/child relation so I can use getParent(). Thanks in advance!