문제

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

도움이 되었습니까?

해결책

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))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top