Created
September 7, 2018 06:39
-
-
Save pyaesone17/0380ffa458741ce195e17ab361bb5709 to your computer and use it in GitHub Desktop.
Fan out Log writer in Go
This file contains hidden or 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
f, err := os.OpenFile("bar.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) | |
if err != nil { | |
log.Fatalf("error opening file: %v", err) | |
} | |
defer f.Close() | |
mw := io.MultiWriter(os.Stdout, f) | |
log.SetOutput(mw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment