Skip to content

Instantly share code, notes, and snippets.

@AlexMocioi
Created July 16, 2013 00:58
Show Gist options
  • Save AlexMocioi/6004922 to your computer and use it in GitHub Desktop.
Save AlexMocioi/6004922 to your computer and use it in GitHub Desktop.
Describe how to log to specific file go app output
func init() {
logf, err := os.OpenFile("log/mid_loop_"+ (time.Now()).Format("2006-01-02_15-04-05") +".log", os.O_WRONLY|os.O_CREATE, 0640)
if err != nil {
log.Fatalln(err)
}
log.SetOutput(logf)
...
}
pe exit inchide go filehandler sau se poate pune explicit in main
defer _ = logf.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment