How to write log to file

后端 未结 11 1267
抹茶落季
抹茶落季 2020-12-07 08:06

I\'m trying to write to a log file with Go.

I have tried several approaches, all of which have failed. This is what I have tried:

func TestLogging(t          


        
11条回答
  •  春和景丽
    2020-12-07 08:41

    I prefer the simplicity and flexibility of the 12 factor app recommendation for logging. To append to a log file you can use shell redirection. The default logger in Go writes to stderr (2).

    ./app 2>> logfile
    

    See also: http://12factor.net/logs

提交回复
热议问题