-
Notifications
You must be signed in to change notification settings - Fork 123
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
Flush log output for info and higher level #527
Conversation
Note: The failing test is unlelated and fixed in PR #528 |
do we really want to do this unconditionally? |
would running with |
8e5b8b7
to
f6d542d
Compare
Addressed the original comment by adding a config option to enable this conditionally. I never had this problem with other dockerized services, but they usually use an existing log library, which does everything. Only in the case of vzlogger I was not gettting any output until I started adding the flush. |
can you add that parameter to the example vzlogger.conf? |
I would prefer to not add more (unnecessary?) options to the configuration. Therefore my question: |
@J-A-U: i suggested the alternative to flush() by default but only for messages of some minimum level. (as in, for errors but not for debug.) this whole thing doesn't seem a bg priority to me, as i don't think many people will run vzloger in docker. and systemd doesn't seem to have the same issue, at least it was not reported. (or nobody uses it for logging yet? :\ ) |
Here is another post also mentioning the without issue with docker logs, and doing more deep dives: https://stackoverflow.com/questions/36217674/docker-logs-and-buffered-output (6 years old) Looks like it is dependent on the docker log driver, so not everyone encounters it. Flushing for everything >= info would also work, and re-simplify this patch. I am happy to provide which ever solution you decide on. My goal is to see these messages immediately on my setup, ideally with using upstream. So I can either add update the sample (as requested above), or roll back to flush, but then would use everything >= Info What would you prefer? |
There is also another option: Use an existing logging library (though that would introduce another dependency, but it would also make the code simpler). I can also prepare a patch for that if you like. I did a test with python and docker - using "print" statements the log output was delayed, using logger.info statements the output was there immediately. So this issue is not specific to vzlogger or C++ |
thanks, that's exactly the kind of research i had asked for in #527 (comment) |
@maxberger:
|
Updated. Now flushed only for level input and higher. |
not sure why this is not merged yet, |
This is required for docker; without flushing, log outputs to stdout are not written immediately, causing confusion (e.g. only errors on startup)