-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Windows logging to files #11960
Fix Windows logging to files #11960
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix!
UIWriter
also strips trailing newlines, I wonder if that might cause other problems.
Would this also work?
type noErrorWriter struct {
w io.Writer
}
func (w noErrorWriter) Write(p []byte) (n int, err error) {
n, _ := w.w.Write(p)
return n, nil
}
Edit: Oh, I just remembered b4b85bd, which did the opposite of this PR to fix a different bug. So I think we should use something like noErrorWriter
to prevent re-introducing that bug. ui.Info
is not what we want, we just want to drop any errors.
794bf4b
to
2917d0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for debugging and fixing this!
🍒 If backport labels were added before merging, cherry-picking will start automatically. To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/542579. |
🍒✅ Cherry pick of commit 08af4f7 onto |
🍒✅ Cherry pick of commit 08af4f7 onto |
closes #11773
Our logger uses
io.MultiWriter
which at minimum writes toos.Stdout
and optionally to syslog or log file targets.When Consul is run as a Windows Service,
os.Stdout
is not available and any writes by the logger fails silently, which inadvertently stopped writes to other targets because ofio.MultiWriter
's behaviour:This PR uses a
noErrorWriter
wrapper which never returns an error so that even if writes to Stdout fail, writes to syslog and log file are unaffected.