打印日志4CXX异常堆栈跟踪
Print Log4CXX exception stacktrace
使用Log4CXX_ERROR我只能打印e.what()。
catch (const std::exception e)
{
logger->error("exception:" << e.what());
//logger->error("exception:" << e); //not allowed
}
如何使用 log4cxx 打印异常堆栈跟踪?
首先添加一个处理程序函数:
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);
}
然后调用此函数以在 STDERR 上转储堆栈跟踪。
相关文章:
- 用于解析 win64 堆栈跟踪的命令行客户端(可以访问符号服务器)
- 提升堆栈跟踪不显示函数名称和行号
- cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 class4.exe.sta
- 如何按指针查看堆栈跟踪
- WinDbg 不显示某些小型转储文件的完整堆栈跟踪
- 发布代码的 gdb 堆栈跟踪可读性如何影响 x64?
- 提升::堆栈跟踪::safe_dump_to输出大小
- Qt 5.9中的QML崩溃-帮助读取堆栈跟踪
- 如何获取崩溃的DLL的堆栈跟踪?
- 当外部源代码中发生异常时,无法正确使用自创建的小型转储文件的堆栈跟踪
- 在 Linux 平台上以 C/C++ 打印进程的所有线程堆栈跟踪
- Boost 堆栈跟踪异步信号安全吗?
- 使用 gdb 时无法获取堆栈跟踪
- VC++ 堆栈跟踪不会解析生产环境中的函数名称
- 从堆栈跟踪中查找共享库中的源代码行
- 捕获异常后的堆栈跟踪
- 是否有一种便携式/标准的方法可以在堆栈跟踪中获取文件名和亚麻布
- 为什么谷歌测试不打印堆栈跟踪或文件名
- 在明夫中打印堆栈跟踪
- GDB 显示奇怪的堆栈跟踪