Pergunta

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

Foi útil?

Solução

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))
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top