Hello,

I downloaded the CVS version 408722 just several days ago and have the following 2 problems with the pattern layout under Linux..

1) %p always shows the current log level, not the level of the message
2) %Q does not print the fractional seconds fo time, but the  "%d{ISO8601}" 
does.

Help, especially on the %p issue is greatly appreciated.

I am using streams in C++.


My code looks like this (inside a class called logWrapper where logger and logs 
are declared static):

                LoggerPtr logWrapper::logger =  Logger::getRootLogger();
                log4cxx::logstream* logWrapper::logs = new 
log4cxx::logstream(Logger::getRootLogger(), Level::INFO);

               ConsoleAppenderPtr append_1(new ConsoleAppender());
               append_1->setName(prefix.c_str());
               append_1->setTarget("System.err");
               append_1->setImmediateFlush(true);

               // note: for log4cxx the %Q does not seem to work as advertised
               //const std::string pattern = "%d{%Y-%m-%d|%H:%M:%S 
%Q}|%-5p|"+prefix+"|%m %n";

               // this gives partial seconds ok
               const std::string pattern = "%d{ISO8601}|%-5p|"+prefix+"|%m %n";

               append_1->setLayout(new PatternLayout(pattern));

               log4cxx::helpers::Pool pool;
               append_1->activateOptions(pool);

               Logger::getRootLogger()->addAppender(append_1);

I'm using this code to set the loglevel, for example:
                logger->setLevel(Level::INFO);
               logs->setLevel(Level::INFO);


And finally I use this macros for logging in my application:
#define LOG_BASE(l,x) \
       {\
       if ( logWrapper::logs->isEnabledFor(l)) \
               {\
               (*logWrapper::logs) << x << LOG4CXX_ENDMSG; \
               } \
       }
#define LOG_INFO(x) LOG_BASE(log4cxx::Level::INFO,x)
#define LOG_WARN(x) LOG_BASE(log4cxx::Level::WARN,x)
#define LOG_DEBUG(x) LOG_BASE(log4cxx::Level::DEBUG,x)
#define LOG_ERROR(x) LOG_BASE(log4cxx::Level::ERROR,x)
#define LOG_FATAL(x) LOG_BASE(log4cxx::Level::FATAL,x)

So my app can do this now:
         LOG_INFO("this is some INFO");

This problem is that if log level has been set to debug, then the above message 
shows up with %p as DEBUG instead of INFO.

Thanks for your help!
-Jeff




Reply via email to