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

Adding logging to the nix-daemon #1829

Open
catern opened this issue Jan 31, 2018 · 8 comments
Open

Adding logging to the nix-daemon #1829

catern opened this issue Jan 31, 2018 · 8 comments
Assignees
Labels
contributor-experience Developer experience for Nix contributors error-messages Confusing messages and better diagnostics feature Feature request or proposal stale UX The way in which users interact with Nix. Higher level than UI.

Comments

@catern
Copy link
Contributor

catern commented Jan 31, 2018

It would be useful if the nix-daemon logged requests it receives and operations it performs. Among other things, this would be useful for:

  • debugging issues when developing the client
  • maintaining a fully detailed log of what Nix operations are performed (useful in both single-user and multi-user installations)
  • performing analytics about Nix usage in a true multi-user installation

It would be straightforward to implement this at a basic level, but there are some questions to consider.

  1. Should the nix-daemon log in plain text or in some structured format?
  2. Should the logging be implemented by nix-daemon itself, or by a separate tool that snoops on nix-daemon communications and summarizes them?
  3. If the nix-daemon logs in plain text to its stderr, how do we differentiate different users and connections which might be interleaved?
  4. Should we include STDERR_NEXT etc messages which are sent to the client in the logs?

The easiest format would be having nix-daemon itself log each request and each response as a single line, and have each line contain information about the connection and user. Something like this, perhaps:

2018-01-31 16:22:47.139 [user:catern,conn:10923123] request: buildPaths bmNormal [ /nix/store/aaaaaaaaaaaaaaaaaaaaaa-things ]
2018-01-31 16:22:47.139 [user:catern,conn:10923123] response: OK
@edolstra edolstra added the feature Feature request or proposal label Jan 31, 2018
@lheckemann
Copy link
Member

Could be related to, though much broader in scope, #1710

@lovasko
Copy link

lovasko commented Mar 29, 2018

I have created a basic version of such logging for all the operation performed by the nix-daemon: lovasko@60be099

Any opinions and/or suggestions? All are welcome! :)

@shlevy
Copy link
Member

shlevy commented Mar 29, 2018

@lovasko Is there a reason to use syslog above just stderr?

@lovasko
Copy link

lovasko commented Mar 29, 2018

@shlevy my thinking was, that since this is a daemon, a fully daemonised process does not have open stdout/stderr streams. This way, syslog provides the ability to produce logs in a fully "stealth" mode. But, since there is the stdio mode, we can still output to the stderr facility by using the LOG_PERROR flag, as described here: http://man7.org/linux/man-pages/man3/syslog.3.html

Sadly, LOG_PERROR isn't fully standard, but is very commonplace.

@edolstra
Copy link
Member

Systemd forwards stderr to the journal. Nix even emits severity levels for use by journald (see SimpleLogger). If syslog support is really desired, it would be better to implement it as a subclass of Logger, rather than putting syslog() calls everywhere.

@edolstra
Copy link
Member

BTW I'm skeptical that logging every request is useful. A typical evaluation can issue thousands of requests, so this will cause some serious log spamming.

@shlevy shlevy added the backlog label Apr 1, 2018
@shlevy shlevy self-assigned this Apr 1, 2018
@jtrakk
Copy link

jtrakk commented Apr 6, 2020

It will be informative if each message contains a uuid and the uuid of its parent task. That way the full task tree can be constructed from the logs. This idea is in OpenCensus, OpenTracing, and Eliot among others.

@stale
Copy link

stale bot commented Feb 15, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 15, 2021
@fricklerhandwerk fricklerhandwerk added error-messages Confusing messages and better diagnostics UX The way in which users interact with Nix. Higher level than UI. contributor-experience Developer experience for Nix contributors labels Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor-experience Developer experience for Nix contributors error-messages Confusing messages and better diagnostics feature Feature request or proposal stale UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

No branches or pull requests

8 participants