Created
July 16, 2013 00:58
-
-
Save AlexMocioi/6004922 to your computer and use it in GitHub Desktop.
Describe how to log to specific file go app output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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