|
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
|