Skip to content
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

Console logging: separation of stdout and stderr #701

Closed
kishorenc opened this issue Aug 20, 2021 · 13 comments · Fixed by #790
Closed

Console logging: separation of stdout and stderr #701

kishorenc opened this issue Aug 20, 2021 · 13 comments · Fixed by #790

Comments

@kishorenc
Copy link

For console logging, it seems like there is no way to configure Glog to send non-error logs to stdout and error logs to stderr.

By default, Glog sends only error logs to stderr, and there is a FLAGS_logtostderr which sends ALL logs to stderr which is not ideal. It will be good to have a flag to log to both stdout and stderr appropriately.

@git-hulk
Copy link
Contributor

@sergiud I would like to have a try. For the design, I don't think we should send non-error logs to stdout when FLAGS_logtostderr was enabled, which would have the breaking change. Do you think we should add another flag to like logtostdout to achieve this feature.

@git-hulk
Copy link
Contributor

apache/kvrocks#478 Kvrocks also wants to log to the stdout which is using glog.

@sergiud
Copy link
Collaborator

sergiud commented Feb 12, 2022

Having logtostdout sounds reasonable. Go ahead!

@git-hulk
Copy link
Contributor

cool, thanks.

@jstiefel
Copy link

As explained in logging.cc, setting the flag logtostdout to True should direct the log messages to stdout instead of logfiles. However, this is definitely not the case for me. I still get the INFO in the logfiles. logtostderr behaves in the same way. This is quite confusing, since there is a alsologtostderr flag which describes this behaviour. To be consistent, wouldn't it make sense to have a alsologtostdout flag, provided that the previous flag doesn't write to the log?

And how does logtostdout interact with stderrthreshold. If I understand correctly, stderrthreshold directs INFO and WARNING to stderr, if I set it to 0. What happens if I set logtostdout at the same time?

@git-hulk
Copy link
Contributor

To be consistent, wouldn't it make sense to have a alsologtostdout flag, provided that the previous flag doesn't write to the log?

@sergiud I will be happy to do this if you think it makes sense.

And how does logtostdout interact with stderrthreshold. If I understand correctly, stderrthreshold directs INFO and WARNING to stderr, if I set it to 0.

You're right that it will send all logs to stderr if set to 0 and logtostdout is enabled.

@jstiefel
Copy link

@sergiud I will be happy to do this if you think it makes sense.

However, I'm not sure how intended behavior should be. During my testing today, both logtostderr and alsologtostderr did the same, i.e. output to log files and stderr. And so did logtostdout. (glog v0.6.0) And this doesn't seem to correspond to the documentation.

@git-hulk
Copy link
Contributor

@jstiefel What's your expected behavior and what you got?

@jstiefel
Copy link

@jstiefel What's your expected behavior and what you got?

logtostderr, alsologtostderr, as well as logtostdout forwarded messages to my terminal as desired. However, they still created entries in the logfile. This is not consistent with the documentation:

"log messages go to stderr instead of logfiles");

(I didn't set any other flags while trying.)

@git-hulk
Copy link
Contributor

Ummm... I tried on my side but it won't send logs to the logfile if one of FLAGS_logtostdout and FLAGS_logtostderr is enabled.

@jstiefel
Copy link

My mistake, I just realized that these flags keep persisting if I don't overwrite them. So no logfiles created now. I think it would be useful to have the alsologtostdout option as well.

@git-hulk
Copy link
Contributor

@sergiud Does this sound good? if yes, i will go ahead to handle this.

@kishorenc
Copy link
Author

Found an issue related to this flag: #943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants