boost log 多模块多文件设置

本文介绍了如何使用Boost Log库配置多模块、多文件的日志记录。通过示例展示了如何在`config.ini`中设置不同日志文件的过滤、格式和旋转策略,以及在`main.cpp`中创建并使用不同日志通道的logger。通过`logging::init_from_stream`从配置文件初始化日志系统,并展示了如何输出不同严重级别的日志到各自指定的文件。
摘要由CSDN通过智能技术生成


[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\""
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值