Hi Paul,
Paul Butcher wrote:
I am having problems with the code within <log4cxx/stream.h>. Using it in a
single source file works fine, but when I try to use it more than once, I get
the following when linking:
In function `operator<<(log4cxx::logstream&, char const*)':
log4cxx/stream.h:153: multiple definition of `operator<<(log4cxx::logstream&,
char const*)'
I can reproduce this. I created some cpp files with content similar to
#include <log4cxx/level.h>
#include <log4cxx/logger.h>
#include <log4cxx/stream.h>
#include "src1.h"
using namespace log4cxx;
static LoggerPtr logger = Logger::getLogger(L"Src1");
void src1() {
logstream info(logger, Level::INFO);
info << "In src1.cpp" << 4.5 << " / " << 4;
info.flush();
}
and then also get a lot of those messages
src1.o(.text+0x0): In function `operator<<(log4cxx::logstream&, char
const*)':
: multiple definition of `operator<<(log4cxx::logstream&, char const*)'
main.o(.text+0x0): first defined here
Maybe I can have a closer look to it tomorrow...
I get the impression that this code is still evolving? Is it ready for "prime
time" yet?
A wider question: what is the preferred mechanism for generating log messages
which are more than just fixed strings?
I think that using a logstream is a proper approach, at least
I like this more than concatenating lots of strings (and probably
do lot of conversions myself) and the using LOG4CXX_ macros. So
something like
logstream info(logger, Level::INFO);
info << "In src1.cpp" << 4.5 << " / " << 4;
seems a proper solution for me.
Regards,
Andreas
--
Andreas Fester
mailto:[EMAIL PROTECTED]
WWW: http://littletux.homelinux.org
ICQ: 326674288