gookit / slog

📑 Lightweight, configurable, extensible logging library written in Go. Support multi level, multi outputs and built-in multi file logger, buffers, clean, rotate-file handling.一个易于使用的,轻量级、可配置、可扩展的日志库。支持多个级别,输出到多文件;内置文件日志处理、自动切割、清理、压缩等增强功能

Home Page:https://pkg.go.dev/github.com/gookit/slog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to compress the (old) log file after rotation?

iredmail opened this issue · comments

Dear developers,

  • How can i configure slog to compress the (old) log file after rotation?
  • 如何在 rotate 之后压缩旧 log 文件?

Thanks for helping. :)

  1. 设置一个稍大于rotate time 的后台定时器,定时处理
  2. 我可以添加一个 hook func,在rotate file完成后触发

rotate 后压缩,这操作非常普遍,建议将它作为一个内置功能,不需要调用者额外处理。优先用 gzip(速度快,虽然压缩比不如 bzip2 等,但较为平衡)。

可以的,下个小版本我加下

太赞了。:)

已经实现,发布了 v0.3.2

非常感谢。:)