Structured logging
- Dominant language
- Erlang
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 9
Description
I’d like to change the way we generate and format log messages inside CouchDB. Currently we use “printf” style invocations of the form `couch_log:Level(Format, Args)` where `Level` is one of the standard syslog levels. In production I find that this approach makes it rather difficult to quickly find log messages that match some criterion. We have multi-line messages, individual values in messages aren’t always labeled, etc. I’ll sometimes end up grep'ing for a bit of text that I know to be unique for a particular message type, but … really? We can do better.
The idea behind structured logging is that the application sends along a set of key-value pairs as an entry to the logging framework. The logger can then invoke one or more handlers to generate different message formats. A dev handler might write out the key-value pairs in a readable key=value format, while in production you might turn on a handler that produces newline-delimited JSON messages which can be easily consumed by any decent logging solution.
I plan to take a pass at converting our existing logging invocations to a more structured format, then see about making the `couch_log` framework less printf-focused in its handler API interface. Comments and ideas welcome.
Contributor guide
Research direction
Start by reviewing the existing couch_log:Level(Format, Args) invocations and the couch_log handler API described in the issue. The work is complete when logging accepts structured key-value entries and handlers can produce readable key=value output or newline-delimited JSON.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- erlang
- Domain
- backend, observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100