enhance(log):调整日志系统配置。
This commit is contained in:
parent
2339e4c725
commit
46ae943653
|
@ -62,6 +62,10 @@ func NewLogMiddleware(config LogMiddlewareConfig) fiber.Handler {
|
|||
fields := []zap.Field{
|
||||
zap.Namespace("context"),
|
||||
zap.String("pid", strconv.Itoa(os.Getpid())),
|
||||
zap.String("method", c.Method()),
|
||||
zap.String("remote", c.IP()),
|
||||
zap.Strings("forwarded", c.IPs()),
|
||||
zap.String("url", c.OriginalURL()),
|
||||
zap.String("time", stop.Sub(start).String()),
|
||||
// zap.Object("response", Resp(c.Response())),
|
||||
// zap.Object("request", Req(c)),
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
@ -14,10 +17,11 @@ func newRollingWriter() io.Writer {
|
|||
return nil
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
return &lumberjack.Logger{
|
||||
Filename: "log/service.log",
|
||||
MaxBackups: 366 * 10, // files
|
||||
Filename: fmt.Sprintf("log/service_%s.log", now.Format("2006-01-02_15")),
|
||||
MaxBackups: math.MaxInt, // files
|
||||
MaxSize: 200, // megabytes
|
||||
MaxAge: 366 * 10, // days
|
||||
MaxAge: math.MaxInt, // days
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user