* feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options. * feat: logx support logs rotation based on size limitation. (#1652) implementation of #1652 Totally compatible with the old logx.LogConf. No effect if users do not change their options.
This commit is contained in:
@@ -8,15 +8,18 @@
|
||||
|
||||
```go
|
||||
type LogConf struct {
|
||||
ServiceName string `json:",optional"`
|
||||
Mode string `json:",default=console,options=[console,file,volume]"`
|
||||
Encoding string `json:",default=json,options=[json,plain]"`
|
||||
TimeFormat string `json:",optional"`
|
||||
Path string `json:",default=logs"`
|
||||
Level string `json:",default=info,options=[info,error,severe]"`
|
||||
Compress bool `json:",optional"`
|
||||
KeepDays int `json:",optional"`
|
||||
StackCooldownMillis int `json:",default=100"`
|
||||
ServiceName string `json:",optional"`
|
||||
Mode string `json:",default=console,options=[console,file,volume]"`
|
||||
Encoding string `json:",default=json,options=[json,plain]"`
|
||||
TimeFormat string `json:",optional"`
|
||||
Path string `json:",default=logs"`
|
||||
Level string `json:",default=info,options=[info,error,severe]"`
|
||||
Compress bool `json:",optional"`
|
||||
KeepDays int `json:",optional"`
|
||||
StackCooldownMillis int `json:",default=100"`
|
||||
MaxBackups int `json:",default=0"`
|
||||
MaxSize int `json:",default=0"`
|
||||
RotationRuleType LogRotationRuleType `json:",default=0,options=[0,1]"`
|
||||
}
|
||||
```
|
||||
|
||||
@@ -37,6 +40,12 @@ type LogConf struct {
|
||||
- `Compress`: 是否压缩日志文件,只在 `file` 模式下工作
|
||||
- `KeepDays`:日志文件被保留多少天,在给定的天数之后,过期的文件将被自动删除。对 `console` 模式没有影响
|
||||
- `StackCooldownMillis`:多少毫秒后再次写入堆栈跟踪。用来避免堆栈跟踪日志过多
|
||||
- `MaxBackups`: 多少个日志文件备份将被保存。0代表所有备份都被保存。当`RotationRuleType`被设置为`LogRotationRuleTypeSizeLimit`时才会起作用。注意:`KeepDays`选项的优先级会比`MaxBackups`高,即使`MaxBackups`被设置为0,当达到`KeepDays`上限时备份文件同样会被删除。
|
||||
- `MaxSize`: 当前被写入的日志文件最大可占用多少空间。0代表没有上限。单位为`MB`。当`RotationRuleType`被设置为`LogRotationRuleTypeSizeLimit`时才会起作用。
|
||||
- `RotationRuleType`: 日志轮转策略类型。默认为`LogRotationRuleTypeDaily`(按天轮转)(整形数值0)。
|
||||
- `LogRotationRuleTypeDaily`(整形数值0): 按天轮转。
|
||||
- `LogRotationRuleTypeSizeLimit`(整形数值1): 按日志大小轮转。
|
||||
|
||||
|
||||
## 打印日志方法
|
||||
|
||||
|
||||
Reference in New Issue
Block a user