On Mar 18, 2008, at 10:25 AM, Stephen Bartnikowski wrote:

Hi Josh,

As far as I can tell support was dropped for those macros, which made me sad too. But it's not too hard to cook up some macros of your own. I did it like
this:

#define LOGGING_DEBUG(message) { \
  if ((*pLogger)->isDebugEnabled()) {\
     log4cxx::logstream oss(*pLogger, log4cxx::Level::getDebug());\
     oss.setLocation(LOG4CXX_LOCATION);\
     oss << message;\
     oss.end_message();}}

This assumes you have the following declared and initialized:
log4cxx::LoggerPtr* pLogger;

Hope this helps you out. I don't know if there's an official way for doing
this.

- Stephen



Support for operator<< in the logging macros was restored last September. It had been dropped since it was not obvious how to allow the macros to work with both wide and byte character strings, but a lot of experimentation hopefully results in a reasonable solution that avoids the surprising expensive cost of std::basic_ostream construction for simple streams and uses the compiler to determine whether to use wide characters based on the first argument.

logstream and the insertional operator support inside the LOG4CXX_ macros serve different goals. The logstream was designed so you could pass it into methods that expected a std::basic_ostream or you could perform a complicated set up involving field widths etc and then reuse it multiple times. The insertion operator support is to simplify formatting that occurs within the scope of one logging request.

Steven, it would be helpful if you could redefine your current macros in terms of the LOG4CXX_ macros and see if there are any unexpected problems.

I'll add some text to the documentation before building the next release candidate.

Reply via email to