boost log 配置实现多模块多文件

本文档详细介绍了如何使用 Boost Log 库配置多模块、多文件的日志系统。通过 `config.ini` 文件设置不同模块的日志输出目的地、过滤条件、格式等,以及在 `main.cpp` 中创建并使用不同通道的 logger,确保每个模块的日志分别记录到不同的文件中,并演示了不同严重级别的日志输出示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



[root@localhost log]# cat config.ini
#comments are allowed. Comment line begins with the '#' character
# and spans until the end of the line.




# Logging core settings section. May be omitted if no parameters specified within it.
[Core]
DisableLogging=false
Filter="%Severity% > debug"




# Sink settings sections
[Sinks.MySink1]


# Sink destination type
Destination=TextFile


FileName="MySink1_%Y-%m-%d_%H-%M-%S_%N.log"


# Sink-specific filter. Optional, by default no filter is applied.
Filter="%Channel% contains \"MySink1\" and %Severity% > info "


# Formatter string. Optional, by default only log record message text is written.
Format="<%TimeStamp%>-<%Severity%>-<%Channel%>:%Message%"


# The flag shows whether the sink should be asynchronous
Asynchronous=false


# Enables automatic stream flush after each log record.
AutoFlush=true


RotationSize=5000000






[Sinks.MySink2]


# Sink destination type
Destination=TextFile


FileName="MySink2_%Y-%m-%d_%H-%M-%S_%N.log"


# Sink-specific filter. Optional, by default no filter is applied.
Filter="%Channel% contains \"MySink2\""


# Formatter string. Optional, by default only log record message text is written.
Format="<%TimeStamp%>-<%Severity%>-<%Channel%>:%Message%"


# The flag shows whether the sink should b
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值