logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: LOG4CXX_DEBUG macro fails when used in a shared object or .so file gcc
Date Wed, 13 Oct 2004 15:40:37 GMT

On Oct 13, 2004, at 1:57 AM, Devender Marri wrote:

>
> Hi Curt,
> Thank you for the reply, atleast I now know that there is indeed a 
> problem, as I was trying different ways to solve the problem.
> currently I am using std::ostrstream to do the same and found that it 
> works.
>
> my new code looks as follows
>
> std::ostrstream outx;
> string str1 = "this is devender ";
> outx << str1;
> int i = 0;
> outx<< i++;
> logger->debug(outx.str());
>


The cost of constructing a std::ostringstream is non-trivial and 
calling logger->debug instead of using LOG4CXX_DEBUG loses the file 
name and line number (there is a bug report documentation to make that 
clear).  I'd recommend the following:

if (logger->isDebugEnabled()) {
    std::ostringstream outx;
    string str1 = "this is devender";
    outx << str1;
    int i = 0;
    outx << i++;
    LOG4CXX_DEBUG(logger, outx,str());
}


Mime
View raw message