-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Should logging really use stderr (and not stdout)? #3460
Comments
It's a common (POSIX) convention. STDOUT used for program output (used when piping to redirecting). STDOUT usually contains meaningful generated or transformed data and STDERR used for diagnostics info (such as app logs). As for
|
Not sure I understand the comment, do we need to change or keep it as is? |
Thanks for your explanation @morigs ❤️. And I totally agree that this makes sense for a (interactive) console application. One could also argue that 'logging' is explicitly configured as an exporter, and that the output of this exporter is real payload in this case (my main argument for a change to STDOUT 😃). Also at least under my configuration STDOUT was always empty (but maybe other receivers, exporters, processors - that I haven't used - distinguish STDOUT from STDERR). And fore sure Personally I still tend to change the behaviour, but to be honest I haven't the overview of the complete ecosystem of all collector components and therefore couldn't estimate the potential consequences of such a change. So whatever is correct in the opinion of the maintainers of this project, I agree - and want to thank you for your effort and your hard work. |
Per POSIX convention, the collector's own logs should be in stderr rather than loggingexporter's. loggingexporter's output is the program's output, not its diagnostics log. |
I think the logging exporter should send to stdout. |
Unfortunately, this causes other tools in the observability chain (OpenObserve, k8s, Loki, DataDog, etc) to report OTEL Collector as continually reporting "errors", so trying to set up alerts on "error count" gets a little more difficult. From the docs it looks like you should be able to set this with:
With the above config, Railway at least starts showing the log entries under their correct color-coded categories for info/warn/error. |
Kubernetes itself seems to output to stderr https://kubernetes.io/docs/concepts/cluster-administration/system-logs/#klog
|
I don't think following Kubernetes conventions makes sense in this case, especially as they also maintain a wrapper Here the collector has an opportunity to distinguish its own (diagnostic) logs from the logs it collects from applications. In my opinion these two programs, particularly the logging collector, have very different goals in mind. Imagine if Docker captured all output, including its own, into stderr. |
In the long term, the collector should be configurable through the same configuration as the OpenTelemetry Configuration schema provides, would the right way to configure this be to have an option on the stdoutlog exporter to specify which writer to use for the different log levels? |
@tonglil maybe I'm misunderstanding what is being said here, but the collector already distinguishes between its own logs and logs it receives from other applications. Its own logs are emitted as configured by the |
We could sidestep the debate by making this configurable easily, no? Then people can have the behavior they want, even if the app defaults to stderr. |
@relistan This is already configurable by setting: service:
telemetry:
logs:
output_paths: stdout |
I am going to close this following #10544. You can configure the logging output with a lot of flexibility, and leveraging the |
Hi, I use the docker image of the opentelemetry-collector and was wondering why the logging information is printed to stderr. I think most tooling expects "docker logs" output to be on stdout. So was it really intended to use stderr here?
opentelemetry-collector/exporter/loggingexporter/factory.go
Line 96 in 3f5c718
Or should a line like
be added to redirect to stdout.
The text was updated successfully, but these errors were encountered: