package log var ( maxSize = 100 // MB outputPath = "/app/logs/app.log" ) type LogConfig struct { AppName string `yaml:"appName"` // 应用名称 Level string `yaml:"level"` // debug, info, warn, error Format string `yaml:"format"` // json, console OutputPath string `yaml:"outputPath"` // 日志文件路径 MaxSize int `yaml:"maxSize"` // 单个日志文件最大尺寸,单位MB MaxAge int `yaml:"maxAge"` // 日志保留天数 MaxBackups int `yaml:"maxBackups"` // 保留的旧日志文件最大数量 Compress bool `yaml:"compress"` // 是否压缩旧日志 } func DefaultLogConfig() *LogConfig { return &LogConfig{ Level: "info", Format: "json", OutputPath: outputPath, MaxSize: maxSize, MaxAge: 7, MaxBackups: 3, Compress: true, } }