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