HardySimpson / zlog

A reliable, high-performance, thread safe, flexsible, clear-model, pure C logging library.
Apache License 2.0
2.25k stars 720 forks source link

zlog分割及删除日志问题 #266

Open ssgnh opened 3 months ago

ssgnh commented 3 months ago

目的

多个分类日志存储再同一个日志记录文件里,限制单个文件的大小和总日志文件的数量

问题

zlog配置如下:

# # 单个日志最大5M,最多存10个
modbus_tcp.INFO     "./logs/bau-%d(%F).log" , 5MB * 10 ~ "./logs/bau-old-%d(%Y%m%d).#2s.log"; detail
main.INFO           "./logs/bau-%d(%F).log"; detail
data_storage.INFO   "./logs/bau-%d(%F).log"; detail
config.DEBUG        "./logs/bau-%d(%F).log"; detail
gpio.DEBUG          "./logs/bau-%d(%F).log"; detail
sqlite3.INFO        "./logs/bau-%d(%F).log"; detail
rs_485_screen.INFO  "./logs/bau-%d(%F).log"; detail
watch_dog.DEBUG     "./logs/bau-%d(%F).log"; detail
pcs_tcp.DEBUG       "./logs/bau-%d(%F).log"; detail
env_dev.INFO        "./logs/bau-%d(%F).log"; detail
can.INFO            "./logs/bau-%d(%F).log"; detail
# # *.*     "aa.log", 100MB ~ "aa-%d(%Y%m%d).#2s.log"
  1. 多个分类存放在同一文件时,限制日志数量和大小的语句5MB * 10 ~ "./logs/bau-old-%d(%Y%m%d).#2s.log",是每个分类都要写上吗?
  2. 在测试时,日志在到底5MB时会自动分割,但是数量超过10时,并没有删除旧日志。请教下,我配置的超过10个日志文件删除,==是指程序不间断运行期间产生超过10个日志文件删除,还是指日志文件夹下总数量超过10个文件才删除==。因为我的测试环境是频繁的运行和关闭程序,生成的日志超过10个时并没有删除,所有猜想是程序不间断运行期间生成的超过10个才删除

期待您的回复!