Ever tried finding out what went wrong with no logs? It’s like trying to find a needle in a haystack in total darkness. While trying the same thing with too many logs is like reading a lengthy saga, trying to find a single sentence…
Logging is an important part of any system, but if you have too many or too few logs, they can be a hindrance.
Here are some tips to get the most out of your logs:
✅ Logs need to be well-structured, clear, and answer the following questions:
- What happened?
- Where?
- When?
While logs can’t directly answer the question “Why something happened”, they need to be clear enough to point you towards the answer.
✅ Understand and use your logging library and be intentional about what gets logged.
✅ Adjust log levels on a granular level, for example, change the level of package Foobar from DEBUG to INFO if it is polluting your debug logs.
✅ Make logs easily searchable, use tools like Sentry to make life easier
✅ READ Your logs! Do this BEFORE you desperately need to, due to a crisis!
✅ Fix warnings as they occur, and if you can not fix them immediately, silence them but create a ticket to address them later.
❌ Do NOT silence warnings globally, be as specific as possible if you do decide to silence a warning
❌ Do not use logs for monitoring
❌ Do NOT log sensitive information like passwords or encryption keys
The goal isn’t more logs, the goal is more useful logs 🏆
They need to answer questions without introducing new ones or hiding anything. Well-crafted logs will enhance your security and make troubleshooting or debugging a more pleasant experience.