-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Normal logs should not go to stderr #3491
Comments
This is not intended behavior. If some CLI commands are using stderr it is a bug. |
@alexmt |
Some of argo-events components also logs to stderr. This should be revisited across the whole argoproj. argoproj/argo-events#884 |
Would love to see this resolved. My stackdriver logs are cluttered with inordinate amounts of error messages coming from argocd, which aren't actually errors - just that info level messages are being output to stderr. And since the messages themselves don't include the severity in a format that stackdriver recognises they default to being logged as errors since they went to stderr. If they go to stdout as they should they would have been logged as info rather than error. |
@jannfis , I am happy to contribute to this. Can you assign this to me ? |
Thanks @iam-veeramalla, much appreciated! I have assigned issue to you :) |
If I am understanding this issue correctly, It can be fairly easy fix by changing the default log from stderr to stdout. The default logging standard of logrus is stderr and can be modified to stdout by setting The real difficulty may be in testing this. Identify the different places where it outputs to stderr and change it to stdout. |
same issue here with argocd: v2.0.0+f5119c0 Running with the following params "app patch-resource --kind Deployment --patch" logs to sdterr instead of stdout |
Same issue |
Also just ran into this, been open a while... Any known simple workarounds? |
@olvesh not yet, we are exploring options for a different logging package as the current project |
Ok. I will try to upgrade to 2.1 tomorrow. As I understand I can set the log-format to json in that version. Perhaps that will remedy some of the logging issues in GKE (the other ones being that GKE fluentbit does not ingest the key=values as separate fields)🤞 On the other hand - why not then log structured logging to stdout and unstructured errors unhandled exeptions to stderr? Guess that this surely has been discussed somewhere, I just havent stumbled over it yet. 😄 |
I'm willing to contribute to addressing this issue. |
Hi @edoger, Please find the response from the community meeting.
Yes. Do we also want to support Sugar logging with Zap ? Do you see any advantages ?
Yes. There is already a log package, if possible we can leverage that.
Yes
Yes
No opinion, You can take this decision. |
@iam-veeramalla thank you very much! |
@iam-veeramalla The internal grpc interceptor seems to have to rely on the logrus implementation. Many functions utilize logrus' global logger for log output capture (which is almost impossible to dynamically modify the output of the global logger in zap). Some test cases rely on logrus' log detection and test modules. I can't quite understand why some source code needs to be designed this way. Lines 73 to 93 in 309654c
|
@edoger We are aware and discussed this in the contributors when @iam-veeramalla presented this issue. This will require a huge refactor in Argo CD. We will need help coordinating all this work. I believe that it is better to map every package that needs to be migrated and provide smaller PRs. This way we will be able to gradually migrate to the new log approach and refactor everything. @iam-veeramalla would you be willing to take this governance task to map and track all work that needs to be done in order to get this 100% implemented? |
I can do that but I will need to get on a call to understand the actual efforts and how we can get it done together 🙂. |
How did it go with this issue ? Did you get started on it? |
Any update on this,please. We are in the same boat. |
Did anybody found a workaround ? |
Quick note that the proposed go-native structured, leveled logging library is available as an experimental package: https://pkg.go.dev/golang.org/x/exp/slog |
The change of complete refactoring is very huge, (╯﹏╰)b, I suggest forking logrus and adding LevelOutput function (I once submitted a function patch, but the author seems not very interested in new functions), and then in go mod replace the package. |
Is there any chance this logging issue could be resolved? |
@edoger I'm not completely opposed to the idea of a fork. Fully replacing the logger is a huge undertaking, and I don't think anyone is currently doing it. If logrus isn't accepting new features, then maintaining a fork should be relatively low-effort. Unless someone wants to take on the full-replacement task. :-) |
Just wanted to point out that in Argo CD Image Updater, we use vanilla logrus with being able to log anything with a level less severe than error to stdout, and error and fatal severities to stderr: https://github.com/argoproj-labs/argocd-image-updater/blob/master/pkg/log/log.go So, it's possible, even if there is some slight overhead through a wrapper. |
Seems like a reasonable opt-in approach, for folks who aren't worried about a little CPU overhead. Maybe even fine as a default, idk how expensive the wrapper is. |
I haven't done any performance tests, but the major part of the overhead would be calling two functions instead of one. There's not much compute involved in that, I guess. |
If it would be acceptable to just log everything (including levels error and fatal) to stdout, it's just a matter of calling logrus' |
I think this is OK for JSON logging. Theoretically , if you're doing structured logging, you can just filter by the value of the |
Should definitely be fine as an opt-in. |
We still have some external dependencies doing their own logging, such as |
The go standard library package |
If anyone is interested in a workaround in the meantime (thanks to @smaftoul 🎉 ), we configured argocd to log as json with the following config :
That way logs are correctly parsed by GCP even if going to stderr. |
Getting back here to point out that logs should indeed keep going to Even if it is a bit counter intuitive, diagnostics output like logs do belong to |
Summary
Normal logs should not go to stderr.
Motivation
Some people including me detect critical issues on k8s by watching pods' stderr logs. But argocd applications are printing their all logs to stderr, and I think this is confused.
Proposal
Basically we should respect the purpose of each stream. Errors go stderr, and normal activity logs go stdout.
The text was updated successfully, but these errors were encountered: