log
This commit is contained in:
6
main.go
6
main.go
@@ -8,6 +8,8 @@ import (
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -16,6 +18,10 @@ func main() {
|
||||
|
||||
r := gin.New()
|
||||
r.Use(session(model.SessionKey))
|
||||
f, _ := os.Create("jx-print.log")
|
||||
//gin.DefaultWriter = io.MultiWriter(f)
|
||||
// 如果需要同时将日志写入文件和控制台,请使用以下代码。
|
||||
gin.DefaultWriter = io.MultiWriter(f, os.Stdout)
|
||||
// LoggerWithFormatter middleware will write the logs to gin.DefaultWriter
|
||||
// By default gin.DefaultWriter = os.Stdout
|
||||
r.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
|
||||
|
||||
Reference in New Issue
Block a user