C++ 日志框架建议
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1736295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C++ logging framework suggestions
提问by Warpin
I'm looking for a C++ logging framework with the following features:
我正在寻找具有以下功能的 C++ 日志框架:
- logs have a severity (info, warning, error, critical, etc)
- logs are tagged with a module name
- framework has a UI (or CLI) to configure for which modules we will actually log to file, and the minimum severity required for a log to be written to file.
- has a viewer which lets me search per module, severity, module name, error name, etc
- 日志具有严重性(信息、警告、错误、严重等)
- 日志用模块名称标记
- 框架有一个 UI(或 CLI)来配置我们将实际记录到文件的模块,以及将日志写入文件所需的最低严重性。
- 有一个查看器,可以让我搜索每个模块、严重性、模块名称、错误名称等
采纳答案by Casey
Not sure about the configuration from a UI or CLI. I've used both of these logging frameworks at one point or other.
不确定来自 UI 或 CLI 的配置。我曾经使用过这两种日志框架。
https://sourceforge.net/projects/log4cplus/
https://logging.apache.org/log4cxx/index.html
https://sourceforge.net/projects/log4cplus/
https://logging.apache.org/log4cxx/index.html
It wouldn't be too hard to drive your logging based on a configuration file that could be editable by hand or through a quick and dirty GUI or CLI app. Might be a bit harder to adjust these dynamically but not too bad.
根据可以手动编辑或通过快速而肮脏的 GUI 或 CLI 应用程序编辑的配置文件来驱动日志记录不会太难。动态调整这些可能有点困难,但还不错。
Update:
更新:
It looks like the proposed Boost.Log is now in Boost 1.54which is at a stable release. If you are already using Boost than I would take a look at it.
看起来提议的 Boost.Log 现在在稳定版本的Boost 1.54中。如果您已经在使用 Boost,那么我会看看它。
回答by ossandcad
回答by dcw
I strongly suggest Pantheios, as it's the only one that's completely type-safe, and is also very efficient. It imposes a little work on the user, in selecting the right "front-end" and "back-end", but once you've got it working, you can just fix and forget.
我强烈建议Pantheios,因为它是唯一一个完全类型安全的,而且非常高效。它在选择正确的“前端”和“后端”方面给用户带来了一些工作,但是一旦你让它工作了,你就可以修复并忘记。
It doesn't provide sophisticated logging facilities - e.g. rolling files - but that's by design, because it's intended to be used in combination with other logging libraries that have more functionality (but poorer performance / type-safety).
它不提供复杂的日志工具——例如滚动文件——但这是设计使然,因为它旨在与具有更多功能(但性能/类型安全性较差)的其他日志库结合使用。
回答by JamieH
If you care about performance, I suggest you check out Pantheios. In particular, it's got very high performance, and it can be used in combination with other logging libraries -- it acts as an efficient and type-safe layer between the logging library (such as log4cxx) and your application code.
如果您关心性能,我建议您查看Pantheios。特别是,它具有非常高的性能,并且可以与其他日志库结合使用——它充当日志库(例如 log4cxx)和您的应用程序代码之间的高效且类型安全的层。
回答by Igor
Pantheiosis a good candidate in term of perormance but my personal preference is P7library. My internal tests (CPU i7-4870HQ, SSD) shows that P7 is faster than Pantheios.
Pantheios在性能方面是一个不错的选择,但我个人更喜欢P7库。我的内部测试(CPU i7-4870HQ,SSD)显示 P7 比 Pantheios 快。
- Pantheios writes 1.8M logs lines per second (time & text message)
- P7 writes 2.4M logs lines per second (time, thread, CPU core, function, file, line and text message)
- Pantheios 每秒写入 180 万行日志(时间和文本消息)
- P7 每秒写入 2.4M 行日志(时间、线程、CPU 内核、函数、文件、行和文本消息)
回答by nhaa123
You could use wxWidgetsand use it's excellent classfor logging. It's rather easy and straightforward. For instance, you can create a dialog which gathers all your logs (e.g. wxLogError, wxLogMessage, wxLogDebug, etc.).
您可以使用wxWidgets并使用它的优秀类进行日志记录。这是相当简单和直接的。例如,您可以创建一个对话框来收集所有日志(例如 wxLogError、wxLogMessage、wxLogDebug 等)。