mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
example: log rotate (#3137)
This commit is contained in:
8
example/os/log/rotate/config.toml
Normal file
8
example/os/log/rotate/config.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[logger]
|
||||
path = "./log"
|
||||
file = "{Y-m-d-H-i}.log"
|
||||
level = "all"
|
||||
stdout = true
|
||||
rotateExpire = "1m"
|
||||
rotateBackupLimit = 4
|
||||
rotateCheckInterval = "5s"
|
||||
23
example/os/log/rotate/main.go
Normal file
23
example/os/log/rotate/main.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
mylog := g.Log()
|
||||
for {
|
||||
mylog.Debug(ctx, "debug")
|
||||
time.Sleep(time.Second)
|
||||
mylog.Info(ctx, "info")
|
||||
time.Sleep(time.Second)
|
||||
mylog.Warning(ctx, "warning")
|
||||
time.Sleep(time.Second)
|
||||
mylog.Error(ctx, "error")
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user