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

Non-error logs are printed to stderr #5331

Open
ku1ik opened this issue Feb 6, 2022 · 2 comments
Open

Non-error logs are printed to stderr #5331

ku1ik opened this issue Feb 6, 2022 · 2 comments

Comments

@ku1ik
Copy link

ku1ik commented Feb 6, 2022

Describe the bug

As in title. This makes alerting configuration based on log severity problematic because everything printed by loki itself seems to be an error. Most logging aggregation tools and platforms treat stderr output as level=error.

For example:

2022-02-06 11:42:17 | level=info ts=2022-02-06T10:42:17.760239159Z caller=table.go:362 msg="finished uploading table index_19029

^^^ not an error but it's logged to stderr.

To Reproduce

Steps to reproduce the behavior:

  1. Start Loki (2.4.2)
  2. Wait until it prints its standard log messages (e.g. db, table related info)

Expected behavior
Informational logs are printed to stdout, and only errors are printed to stderr.

Environment:

  • bare-metal
@muffl0n
Copy link

muffl0n commented Apr 5, 2022

This seems to be defined here:

loki/pkg/util/log/log.go

Lines 46 to 49 in 46956d0

logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
if format.String() == "json" {
logger = log.NewJSONLogger(log.NewSyncWriter(os.Stderr))
}

I'm not sure how one would fix this. Just changing the code to log.NewLogfmtLogger(log.NewSyncWriter(os.Stdout)) is wrong either, cause everything above "WARN" should be printed to stderr furthermore.

It's similar for promtail, btw.

@munsayac13
Copy link

munsayac13 commented May 11, 2022

Im having similar issue. We are using loki with fluentbit. Loki version 2.5.0 and Fluentbit 2.1.0 under kubernetes cluster 1.21

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

Successfully merging a pull request may close this issue.

3 participants