Debugging 10x Faster with your Logs
Developers & administrators can spend way less time debugging when properly using their logs.
Technical teams spend way too much time investigating why a running application did not do exactly what it was supposed to do. This is due to several reasons:
- Production environments never react as QA or dev
- The amount of data in log files is too big to get analyzed without appropriate tools
- Tech teams react to unexpected problems and don’t have time to solve them pro-actively
We’re sharing in this short article our top 2 debugging best practices you can implement to save time in a crisis.
1) Tidying up regularly before facing a debugging crisis
Let’s illustrate this with Java debugging. Properly formatted, each log event provides the classname and the severity level. If the code is properly written, these classes should emit warnings and errors when appropriate. With this information, you can arrange to spot small issues before they get bigger and out of hand.
At Logmatic.io, we ask our developers to analyze the severity situation of each piece of code on a regular basis. To do so, we use bi-dimensional leaderboards as illustrated on the figure below:
Java debugging leaderboard
We then pick & solve the most relevant ones in order to get our code safer. Indeed, 80% of your problems come from 20% of the causes as explained by the Pareto principle. So when we’re fixing the right ones, our debugging future becomes much brighter!
2) Getting rich, detailed information by adding context to your logs
A user complains that something went wrong, for ex. clicking or downloading features were not working, or downloading is not working. And digging in all your logs to understand what happened during one of their actions will take you a while… so you’re faced with either doing the ostrich and bury your hand in the sand, or actually diving into your logs for a while to hand pick the information you need for debugging. This is why we encourage tech teams to add context to their log events.
For instance and as illustrated below, Logmatic.io’s tech team added a “scope” attribute to log events – checkout Mapped Diagnostic Context (MDC):
So if one of our user is attached to a specific scope we filter out all the non interesting logs in one click.
Implementing context addition requires developers to follow some common standards when implementing their classes. But taking the time to define and implement these standards is worth the time you’re going to save when debugging!
You now know our top 2 best practices to pro-actively ensure fast debugging: a crisis is always properly dealt with when properly planned for!