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

Était-ce utile?

La 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))
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top