實施 Logrus Go 包。文件已保存,但停止在控制臺上打印日志,僅在創(chuàng)建的名為供應(yīng)商.log 的 .log 文件中可見。這是當前使用的代碼。package loggingimport ( "fmt" "os" mylog "github.com/sirupsen/logrus")// InitializeLogging asdasfunc InitializeLogging(logFile string) { var file, err = os.OpenFile(logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { fmt.Println("Could Not Open Log File : " + err.Error()) } mylog.SetOutput(file) //log.SetFormatter(&log.TextFormatter{}) mylog.SetFormatter(&mylog.JSONFormatter{})}
- 2 回答
- 0 關(guān)注
- 151 瀏覽
添加回答
舉報
0/150
提交
取消