Boost.Log配置文件 [英] Boost.Log Configuration Files

查看:346
本文介绍了Boost.Log配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将日志记录添加到旧的C ++程序中.经过研究,我决定使用增强日志 .文档中包含创建接收器和过滤器的示例.但是,我找不到任何日志配置文件示例.

I'm adding logging to an old C++ program. After some research, I've decided to use Boost Log . The documentation is filled with examples of creating sinks and filters. However, I couldn't find any example of a log configuration file.

是否有一种方法可以配置不需要编译的文件的日志记录?类似于log4net有什么?还是Python(好吧,因为Python仍然没有被编译...)?

Is there a way to configure logging from a file that doesn't have to be compiled? Similar to what log4net has? Or Python (well, since Python isn't compiled, anyway...) ?

推荐答案

最终,我找到了官方文档,或者是最近添加的,或者它已经被很好地隐藏起来,所以我以前没看过它:

Eventually I found the official documentation, either it was added recently, or it is well hidden so that I didn't see it before:

http://www.boost.org/doc/libs/1_57_0/libs/log/doc/html/log/detailed/utilities.html#log.detailed.utilities.setup.settings_file

不幸的是,我也找不到详尽的答案,但有一些观察结果:

Unfortunately, I can't find an exhaustive answer neither, but some observations:

当然可以使用配置文件:

Certainly it is possible to use a configuration file:

boost :: log :: init_from_stream(std :: basic_istream< CharT>&)

文件示例(来自提升日志的严重性_logger init_from_stream ) :

[Sinks.MySink]
Destination=Console
Format="%LineID%: <%Severity%> - %Message%"

通过以下链接,您可以识别其他有效的设置键和值(例如Destination = TextFile,Filter =,AutoFlush =,FileName =)

From the following link you can identify additional valid setting keys and values (e.g. Destination=TextFile, Filter=, AutoFlush=, FileName=)

boost的parser_utils.hpp中的常量给出了配置文件默认支持的关键字的另一种想法(例如,[Core]部分带有DisableLogging键).

Constants in boost's parser_utils.hpp give another idea of keywords that are by default supported by the configuration file (E.g. section [Core] with key DisableLogging).

此处介绍了用户定义类型的提供设置(在页面末尾带有配置文件的相应片段):

Providing settings for user defined types is described here (with a corresponding snippet of the configuration file at the end of the page):

http://www.boost.org/doc/libs/1_57_0/libs/log/doc/html/log/extension/settings.html

在我看来,很难找到配置文件格式条目的描述,因为有效条目是从实现接收器,过滤器等的源代码派生的.此实现甚至可以由用户定义,因此无法给出明确的配置格式说明.

It seems to me that it is difficult to find a description of the configuration file format entries because the valid entries are derived from the source code implementing the sinks, filters etc. This implementation may be even user defined so it is impossible to give explicit configuration format description.

也许您可以尝试以编程方式创建配置,然后将其转换为配置文件的形式时,可以针对无法找到如何设置它们的特定属性打开单独的问题.

Maybe you can try to create your configuration in a programmatic way and when transforming it to the form of the configuration file, you can open separate questions for the particular properties that you are not able find out how to set them.

这篇关于Boost.Log配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆