1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 16:42:41 +08:00
Files
go-mixed/logx/readme.md
2022-07-29 09:46:29 +08:00

27 lines
760 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 日志记录组件
日志分割及备份
日志可按照日期或大小进行分割,保留的历史日志文件数量由备份数量决定。
1. 按天拆分每天生成新的日志文件名称。格式为file.yyyy-mm-dd.log 其中file和log为配置的日志文件名称。
2. 按大小拆分使用lumberjack组件对日志文件进行分割。
3. 按时间间隔拆分,日志文件按照指定的间隔拆分,
日志输出流
支持控制台和文件输出,可扩展输出组件
``` golang
logx.NewLogger(
WithLevel("debug"),
WithFormatter(),
WithConsole(),
WithRoateBySize(FileRoateSize{
MaxSize
MaxAge
MaxBackups
}),
WithRoateByDate("filename", MaxAge, MaxBackups),
WithFile("filename"))
```