Tips for logging
Everyone does logging a bit differently and what is considered best practice can vary across projects and time. However, there are some things you should be aware of.
Keywords when using structured logging
When using any kind of structured logging, try to make sure to share common keywords, such as request and user IDs, while also trying to avoid conflicting keywords used for similar, but not exactly the same, things. Depending on the backing database, you might also run into issues with types here, for example, in a situation where user
might be the key for an integer, a string, or its own nested structure, like a JSON object.
Sometimes it’s possible to avoid any overlaps by creating per-service namespaces and keeping a list of “globally used” keys, along with definitions for them.
Severity
When developing software, it makes sense to have some internal document explaining which severity has which meaning. This avoids situations...