Closed willywartono14 closed 7 months ago
so i want rollover the log file when the size log higher then maxSize but there is nothing happen. anyone can help ? Thank you this is my Code :
`
func InitOrientalGaming(ctx context.Context, cfg *ogcfg.Config) *zerolog.Logger { var multi zerolog.LevelWriter consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout, NoColor: true, TimeFormat: time.RFC3339} consoleWriter.FormatLevel = func(i interface{}) string { return strings.ToUpper(fmt.Sprintf("[ %-6s]", i)) } consoleWriter.FormatTimestamp = func(i interface{}) string { return strings.ToUpper(fmt.Sprintf("[%s] -", i)) } consoleWriter.PartsOrder = []string{ zerolog.LevelFieldName, zerolog.TimestampFieldName, zerolog.CallerFieldName, zerolog.MessageFieldName, } if cfg.Logger.WriteLogger { multi = zerolog.MultiLevelWriter(consoleWriter, NewRollingFile(cfg)) } else { multi = zerolog.MultiLevelWriter(consoleWriter) } ctx = zerolog.New(multi).Level(zerolog.TraceLevel). With(). Timestamp(). Logger().WithContext(ctx) log := zerolog.Ctx(ctx) return log } func NewRollingFile(cfg *ogcfg.Config) io.Writer { ljLog := &lumberjack.Logger{ Filename: path.Join(cfg.Logger.PathLogger, cfg.Logger.FileNameLogger), MaxBackups: cfg.Logger.MaxBackUpLogger, // files MaxSize: cfg.Logger.MaxSizeLogger, // megabytes MaxAge: cfg.Logger.MaxAgeLogger, // days Compress: false, } return ljLog }
so i want rollover the log file when the size log higher then maxSize but there is nothing happen. anyone can help ? Thank you this is my Code :
`
`