更好的 C++ 日志库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6692238/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 20:32:56  来源:igfitidea点击:

Better logging library for C++

c++logging

提问by Olympian

In our project now we using log4cxx, but those library don't develope some years, also we have some problems with it. Could you advise some library for logging in C++. Library must support multithreade logging, system-log. Also it'll be good if it support logging via << operator. Also lib license must be very democracy - like boost, apache etc Crossplatform support. Must support linux, windows. Better if it support solaris, aix, hp-ux, but it's not necessary.

在我们的项目中,我们现在使用 log4cxx,但是这些库几年没有开发,我们也遇到了一些问题。您能否建议一些用于登录 C++ 的库。库必须支持多线程日志记录、系统日志。如果它支持通过 << 操作符进行日志记录也会很好。此外,lib 许可证必须非常民主 - 如 boost、apache 等跨平台支持。必须支持linux、windows。如果支持solaris、aix、hp-ux就更好了,但不是必须的。

采纳答案by stijn

boost::logis probably the most versatile and well-written logging library I've seen. It's pretty complicated but really genius at the same time. And it does everything you can think of and then some more.

boost::log可能是我见过的最通用、写得最好的日志库。这非常复杂,但同时又非常天才。它会做你能想到的所有事情,然后还有更多。

回答by rafak

I use the gloglibrary, by google (because I could not install Boost.Log easily). It is both simple to use and powerfull.

我使用谷歌的glog库(因为我无法轻松安装 Boost.Log)。它既易于使用又功能强大。

回答by vrince

We use log4cplusin our company, it provides a complex hierarchical logging system (based on log4j). It seems to have everything you are asking for. It provides many appenders(I personally choose this library for the rolling files linux/windows and linux Syslog).

我们公司使用log4cplus,它提供了一个复杂的分层日志系统(基于log4j)。它似乎拥有您所要求的一切。它提供了很多appenders(我个人为滚动文件 linux/windows 和 linux Syslog 选择了这个库)。

The library is quite simple to compile and deploy on both linux & windows And do the job no problem so far (about 4 years in production).

该库在 linux 和 windows 上编译和部署都非常简单,并且到目前为止没有问题(大约 4 年的生产)。

Only drawback, the lack of documentation but the code it quite self-explanatory. Good new is you could go to the log4j documentation page to understand how configurators/patterns/etc works ...

唯一的缺点,缺乏文档但代码很不言自明。好消息是你可以去 log4j 文档页面了解配置器/模式/等是如何工作的......

回答by Alok Save

Check out pantheios!

检查泛神