-
Notifications
You must be signed in to change notification settings - Fork 105
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 #118
Comments
This should be handled with #110, which also introduce log levels |
Nice! |
@proggaras Did it though? Because I still get all logs through stderr even today. I was just browsing through my logs, an all logs generated by pihole exporter - even though they say level=info in the body - are still logged to stderr, not stdout. Maybe I'm missing something though? |
~/tmp/2024-08-21
➜ ./pihole_exporter-darwin-amd64 > foo
INFO[0000] ------------------------------------
INFO[0000] - PI-Hole exporter configuration -
INFO[0000] ------------------------------------
INFO[0000] Go version: go1.20.1
INFO[0000] PIHoleProtocol : [http]
INFO[0000] PIHoleHostname : [127.0.0.1]
INFO[0000] PIHolePort : [80]
INFO[0000] Port : 9617
INFO[0000] Timeout : 5s
INFO[0000] ------------------------------------
INFO[0000] New Prometheus metric registered: domains_blocked
INFO[0000] New Prometheus metric registered: dns_queries_today
INFO[0000] New Prometheus metric registered: ads_blocked_today
INFO[0000] New Prometheus metric registered: ads_percentag_today
INFO[0000] New Prometheus metric registered: unique_domains
INFO[0000] New Prometheus metric registered: queries_forwarded
INFO[0000] New Prometheus metric registered: queries_cached
INFO[0000] New Prometheus metric registered: clients_ever_seen
INFO[0000] New Prometheus metric registered: unique_clients
INFO[0000] New Prometheus metric registered: dns_queries_all_types
INFO[0000] New Prometheus metric registered: reply
INFO[0000] New Prometheus metric registered: top_queries
INFO[0000] New Prometheus metric registered: top_ads
INFO[0000] New Prometheus metric registered: top_sources
INFO[0000] New Prometheus metric registered: forward_destinations
INFO[0000] New Prometheus metric registered: querytypes
INFO[0000] New Prometheus metric registered: status
INFO[0000] Creating client with config <Config@C000282058 PIHoleProtocol=http, PIHoleHostname=127.0.0.1, PIHolePort=80>
INFO[0000] Starting HTTP server
^C2024/08/21 10:41:05 pihole-exporter HTTP server stopped
~/tmp/2024-08-21
➜ cat foo
~/tmp/2024-08-21
➜ ./pihole_exporter-darwin-amd64 > foo 2>&1
~/tmp/2024-08-21
➜ head foo
time="2024-08-21T10:41:10+02:00" level=info msg=------------------------------------
time="2024-08-21T10:41:10+02:00" level=info msg="- PI-Hole exporter configuration -"
time="2024-08-21T10:41:10+02:00" level=info msg=------------------------------------
time="2024-08-21T10:41:10+02:00" level=info msg="Go version: go1.20.1"
time="2024-08-21T10:41:10+02:00" level=info msg="PIHoleProtocol : [http]"
time="2024-08-21T10:41:10+02:00" level=info msg="PIHoleHostname : [127.0.0.1]"
time="2024-08-21T10:41:10+02:00" level=info msg="PIHolePort : [80]"
time="2024-08-21T10:41:10+02:00" level=info msg="Port : 9617"
time="2024-08-21T10:41:10+02:00" level=info msg="Timeout : 5s"
time="2024-08-21T10:41:10+02:00" level=info msg=------------------------------------ As you see above, when I redirect output with |
As in title. This makes alerting configuration based on log severity problematic because everything seems to be an error. Most logging aggregation tools and platforms treat stderr output as level=error.
For example, "New tick of statistics from 10.9.1.100: 2497 ads blocked / 26870 total DNS queries" is not an error but it logged to stderr.
Steps for Reproduction
Run the exporter, redirect stderr to a file, observe all logs being saved there.
Expected behavior:
Informational logs are printed to stdout, and only errors are printed to stderr.
Actual behavior:
All logs, including informational, are printed to stderr.
Platforms:
Ubuntu 20.04, x86 64-bit
Versions:
0.1.1
The text was updated successfully, but these errors were encountered: