hi,
I run the example of log4cxx on the apache site.
// include log4cxx header files.
#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"

using namespace log4cxx;
using namespace log4cxx::helpers;

LoggerPtr logger(Logger::getLogger("MyApp"));

int main(int argc, char **argv)
{
        int result = EXIT_SUCCESS;
        try
        {
                // Set up a simple configuration that logs on the console.
                BasicConfigurator::configure();

                LOG4CXX_INFO(logger, "Entering application.");
                LOG4CXX_INFO(logger, "Exiting application.");
        }
        catch(Exception&)
        {
                result = EXIT_FAILURE;
        }

        return result;
}

But when I run it, I got segement fault error when the program exits. But it
works fine when "LoggerPtr logger(Logger::getLogger("MyApp"));" is inside
the main function.

More ever, When I declare a static LoggerPtr in a A.h as its memeber, and
initialize it in the A.cpp using
in the A.h
private:

static log4cxx::LoggerPtr;

in the A.cpp
logger = log4cxx::Logger::getLogger("A");

It also will a segement fault error when the program exits.

It make me crazy.  I almost can't use it.

Could anyone help me solve it ??

Thank you very much.


-- 
JinBiao Liu

Reply via email to