How to write log to file

后端 未结 11 1270
抹茶落季
抹茶落季 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:49

    If you run binary on linux machine you could use shell script.

    overwrite into a file

    ./binaryapp > binaryapp.log
    

    append into a file

    ./binaryapp >> binaryapp.log
    

    overwrite stderr into a file

    ./binaryapp &> binaryapp.error.log
    

    append stderr into a file

    ./binaryapp &>> binalyapp.error.log
    

    it can be more dynamic using shell script file.

提交回复
热议问题