How to write log file

func main() {
    // Disable Console Color, you don't need console color when writing the logs to file.

    // Logging to a file.
    f, _ := os.Create("gin.log")
    gin.DefaultWriter = io.MultiWriter(f)

    // Use the following code if you need to write the logs to file and console at the same time.
    // gin.DefaultWriter = io.MultiWriter(f, os.Stdout)

    router := gin.Default()
    router.GET("/ping", func(c *gin.Context) {
        c.String(200, "pong")

Last modified March 1, 2020: fix index error (#112) (7c0ba31)