logFile, err := os.Create("production.log")
if err != nil {
panic(err)
}
gin.DefaultWriter = io.MultiWriter(logFile, os.Stdout)
r := gin.Default()
^ I was expecting everything to be logged into a file & stdout. Everything is being logged into stdout but not everything is being logged into the file. Only http request logs are being logged:
[GIN] 2017/02/15 - 21:55:33 | 200 | 4.382883167s | 112.198.83.128 | POST /api/events
Logs generated by log.Println("test") are not being logged in the file.
log.SetOutput(gin.DefaultWriter) // You may need this
log.Println("test")
@basco-johnkevin in your example, you are changing the logger of gin, not of log. Check @lawlite answer.
Most helpful comment