On Feb 13, 2007, at 9:52 AM, Steve wrote:

I'm running into a problem when I get a logger that is not in my
configuration file. The logger appears to be created with a
null Level. How can I check if the level is null so I can
set it to a default value ? Thanks.

e.g.

log4cxx::PropertyConfigurator::configure("some-config-filename");
LoggerPtr logger = log4cxx::Logger::getLogger("some-logger-name");
LevelPtr level = logger->getLevel();

/* at this point it looks like level's private "p" member is null */

Should just be:

if (level == 0) {
    level == Level::getDebug();
}

p.s. your code can be a little more efficient (but deviating from Java style) if written like:

LoggerPtr logger(log4cxx::Logger::getLogger("some-logger-name"));
LevelPtr level(logger->getLevel());

Reply via email to