1

Using Log4CXX_ERROR I can only print e.what().

catch (const std::exception e)
{
    logger->error("exception:" << e.what());
    //logger->error("exception:" << e); //not allowed
}

How can I print exception stack trace using log4cxx?

1 Answer 1

1

First Add a handler function:

void trace() {
    void *array[20];
    size_t size;

    /* store up to 20 return address of the current program state in array
       and return the exact number of values stored */
    size = (size_t)backtrace(array, 20);

    /* return names of functions from the backtrace list in array and
       write result immediately to stderr */
    backtrace_symbols_fd(array, size, STDERR_FILENO);
}

and, then call this function to dump stack trace on stderr.

Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't answer the question as to how to log them using log4cxx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.