Hi Tomas,
I don't have a whole lot of time to confirm your errors, but it looks like
you could get around some of your issues here by taking advantage of
log4cxx::logstream. I always do something like the following:
log4cxx::logstream oss(*sm_logger, log4cxx::Level::getDebug());
oss << "This is a number test: " << a;
oss.flush();
You could rig it up in your own macro and do things like:
MY_LOG4CXX_DEBUG( "This is a number test: " << a );
Hope this helps!
Stephen Bartnikowski
Barking Lizards Technology
www.barkinglizards.com
________________________________________
From: Tomas Andersen [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 21, 2006 4:22 AM
To: [email protected]
Subject: Possible error with logging a stringstream
Hi!
When using log4cxx I usually do something like this to build the log string.
std::stringstream oss;
oss << "This is my logging and the result is: ";
int i=getANumber();
if( i == 1 )
{
oss << "1";
}
else
{
oss << "something else";
}
LOG4CXX_DEBUG(logger, oss.str();
nextMethodToCall();
[This works ok.]
One time I added
oss << std::ends;
before the LOG4CXX_DEBUG call.
This log line never appeared in the log and the nextMethodToCall() method
was never called. It seemed like the
thread where this was done hanged in the LOG4CXX_DEBUG call!
Great if you could check that. I'm using the head version of LOG4CXX
downloaded the 19. december this year =)
Another thing while I'm at it:
I have used the LOG4CXX_DEBUG command with concatuating several
std::string(s) as parameters, ie:
LOG4CXX_DEBUG(logger, "This is a string: " + myFirstString + " and this is
another one: " + myOtherString );
It does only work with strings. Do you have any plans of making this
possible for other types aswell (as in log4j)..?
(I know java has the advantage of toString() and that is probably why this
doesn't work right?)
int a = 5;
LOG4CXX_DEBUG(logger, "This is a number test: " + a);
It compiled but resulted in the following logline:
.... - is a number test:
The first word was cut and the integer was never printed.
Happy Christmas from
Tomas Andersen
Consultant
www.morecom.no