> -----Original Message----- > From: Josh Kelley [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 18, 2008 9:10 AM > To: log4cxx-user@logging.apache.org > Subject: Use of operator<< > > I saw that I can use the << operator within the LOG4CXX_DEBUG, etc. > macros; e.g.: > > LOG4CXX_DEBUG(logger, "Read " << path << " and got " << out); > > This seems very convenient (and a whole lot more convenient > than formatting strings myself or having to use something > like boost::format for every log statement), but as far as I > can tell, it's undocumented. Is this use of operator<< > officially supported, or is it an implementation detail that > I should not be relying upon? > > If it is supported, then can I add a wiki page about it? If > it's not supported, then is there a recommended way of doing > formatted logging? > > Thanks. > > Josh Kelley >
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