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

Optional simultaneous debug logging to second file? #5392

Closed
wtogami opened this issue Jul 9, 2022 · 6 comments
Closed

Optional simultaneous debug logging to second file? #5392

wtogami opened this issue Jul 9, 2022 · 6 comments
Assignees
Milestone

Comments

@wtogami
Copy link
Contributor

wtogami commented Jul 9, 2022

Background
#5349 was helpful in enabling debug logging to zoom in on one particular peer node id. It would sometimes be useful when you know in advance how to reproduce an issue. The trouble however is with many rare issues you can't predict ahead of time like #5371 or you can't restart the daemon to change the log-level because doing so workarounds the problem like #5366. Thus if we want better info to always be available we need debug logging enabled. But the full debug firehose is too much to drink. It contains too many useless events that detract from your ability to see ordinary information in the regular info log.

Proposal: Add an optional simultaneous second log file

# Existing log options behave exactly as before 
log-file=/var/log/lightningd/info.log
log-level=info
log-level=debug:plugin-peerswap-plugin
log-level=debug:02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f
# Second log file
log2-file=/var/log/lightningd/debug.log
log2-level=debug

With the option for two log files you could have the best of both worlds. The normal log would remain useful while users can opt into a second debug log containing whatever firehose they want. That way when an unpredictable bug happens the best possible information is available for reporting.

Notes

  • log2 would be disabled by default. log2-file can only be a file, not stdout like the default behavior of the main log.
  • Documentation would show an example using logrotate to rotate the log2-file every day with 7 days expiry. This should be long enough firehose retention to recover whatever info is needed from a recent event. SIGHUP should behave the same on both log files.

Thoughts?

@rustyrussell
Copy link
Contributor

Already implemented for 0.12: 6ed5f31

@wtogami
Copy link
Contributor Author

wtogami commented Jul 9, 2022

Would it be feasible to have separate filtering for each log file like the above example? It appears that isn't currently implemented?

@rustyrussell rustyrussell self-assigned this Jul 14, 2022
@rustyrussell rustyrussell added this to the v22.10 milestone Jul 14, 2022
@rustyrussell
Copy link
Contributor

Hmm, maybe we allow filename at the beginning of 'log-level', like:

log-file=/var/log/lightningd/info.log
log-level=/var/log/lightningd/info.log:info

Awkward, but allows : in log filenames.

@zerofeerouting
Copy link
Contributor

That would be great, especially if it would allow for the same level of granularity as before.

This way you can have your regular info level log and a channel specific debug log to another destination.

@zerofeerouting
Copy link
Contributor

@rustyrussell - just a quick question - would it look like this?

log-file=/var/log/lightningd/info.log
log-file=/var/log/lightningd/debug-chan55.log
log-level=/var/log/lightningd/info.log:info
log-level=/var/log/lightningd/debug-chan55.log:debug:chan#55

@wtogami
Copy link
Contributor Author

wtogami commented Jul 26, 2022

It would work fine either way but it would be cleaner and less error prone if you specify filenames only once per logX-file entries? You could put colons in those filenames if you want.

@cdecker cdecker modified the milestones: v22.11, v23.02 Dec 1, 2022
@rustyrussell rustyrussell modified the milestones: v23.02, v23.05 Feb 6, 2023
@ShahanaFarooqui ShahanaFarooqui modified the milestones: v23.05, v23.08 Apr 5, 2023
rustyrussell added a commit to rustyrussell/lightning that referenced this issue Jul 17, 2023
Fixes: ElementsProject#5392
Changelog-Added: config: `log-level` can be specified on a per-logfile basis.
rustyrussell added a commit to rustyrussell/lightning that referenced this issue Jul 19, 2023
Fixes: ElementsProject#5392
Changelog-Added: config: `log-level` can be specified on a per-logfile basis.
rustyrussell added a commit to rustyrussell/lightning that referenced this issue Jul 19, 2023
Fixes: ElementsProject#5392
Changelog-Added: config: `log-level` can be specified on a per-logfile basis.
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

No branches or pull requests

5 participants