Given those comments (thanks for pointing them out), I definitely will not define logstreams in my headers. The style of code that I prefer uses iostreams, so for example this type of log statement:
logstream << Level::getInfo() << "Player started with SYPHON " << SYPHON << ", FBO " << FBO << ", DEMO " << DEMO << LOG4CXX_ENDMSG; which, if possible to do with those macros would be nice, but worse case adding a logstream definition in a function really isn't the end of the world. On Mon, Jan 13, 2014 at 1:27 PM, Rhys Ulerich <rhys.uler...@gmail.com>wrote: > > I'd like to avoid having to create a logstream definition in every > function > > that needs it. > > Is there any way to create a logstream in the header and then attach it > to a > > logger in the constructor? > > Could you give an example of the code that you're writing that > requires repeatedly explicitly creating a logstream? > > I ask because I've found the LOG4CXX_xxx macros to be sufficient to > avoid needing logstream-related boilerplate. > > And also because of these comments in the code > > * Instances of log4cxx::logstream > * are not designed for use by multiple threads and in > general should be short-lived > * function scoped objects. Using log4cxx::basic_logstream > as a class member or > * static instance should be avoided in the same manner as > you would avoid placing a std::ostringstream > * in those locations. > > which appear in main/include/log4cxx/stream.h. > > - Rhys >