flag set error : log to file or stderr #371
Labels
kind/bug
Categorizes issue or PR as related to a bug.
triage/accepted
Indicates an issue or PR is ready to be actively worked on.
/kind bug
What steps did you take and what happened:
I try to save log to local file with parameter :
go run main.go -log_dir=logs -logtostderr=false
But errorLogs still will print to stderr!(infoLogs won't)
As the doc say
"stderrthreshold : logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false
.So I tried
go run main.go -log_dir=logs -logtostderr=false -alsologtostderr=true -stderrthreshold=2
andgo run main.go -log_dir=logs -logtostderr=false -alsologtostderr=true -stderrthreshold=3
, but it doesn't work at all.The errorLogs still print to stderr.
So I analyzed the code of klog, finally I find that :
in
klog.go
fileLine 20
.this code tell me I should set alsoToStderr to false, then the stderrThreshold can come into effect. This is contrary to what the documentation says!
I tried
go run main.go -log_dir=logs -logtostderr=false -alsologtostderr=false -stderrthreshold=3
. It worked ! the errorLog didn't print to stderr.What did you expect to happen:
please fix this bug or just update the doc, it's up to you.
Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]
The text was updated successfully, but these errors were encountered: