* 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 @@ English | [简体中文](readme-cn.md)
|
||||
|
||||
```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,11 @@ type LogConf struct {
|
||||
- `Compress`: whether or not to compress log files, only works with `file` mode.
|
||||
- `KeepDays`: how many days that the log files are kept, after the given days, the outdated files will be deleted automatically. It has no effect on `console` mode.
|
||||
- `StackCooldownMillis`: how many milliseconds to rewrite stacktrace again. It’s used to avoid stacktrace flooding.
|
||||
- `MaxBackups`: represents how many backup log files will be kept. 0 means all files will be kept forever. Only take effect when RotationRuleType is `LogRotationRuleTypeSizeLimit`. NOTE: the level of option `KeepDays` will be higher. Even thougth `MaxBackups` sets 0, log files will still be removed if the `KeepDays` limitation is reached.
|
||||
- `MaxSize`: represents how much space the writing log file takes up. 0 means no limit. The unit is `MB`. Only take effect when RotationRuleType is `LogRotationRuleTypeSizeLimit`.
|
||||
- `RotationRuleType`: represents the type of log rotation rule. Default is LogRotationRuleTypeDaily (int value 0).
|
||||
- `LogRotationRuleTypeDaily` (int value 0): rotate the logs by day.
|
||||
- `LogRotationRuleTypeSizeLimit` (int value 1): rotate the logs by size of logs.
|
||||
|
||||
## Logging methods
|
||||
|
||||
|
||||
Reference in New Issue
Block a user