Question

How do I set the martini log path to some random file. It is now displaying in console.

m := martini.Classic()

Thanks for the help

Was it helpful?

Solution

Attach a new logger to Martini:

f, err := os.OpenFile("logfile", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
if err != nil {
    t.Fatalf("error opening file: %v", err)
}
defer f.Close()

m.Map(log.New(f, "[martini]", log.LstdFlags))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top