Art of logging

There are some good suggestions in this article

It talks about having logging as part of initial design and thats very valuable. Logging is crucial
and can be a powerful aspect during the life cycle of software. Making it such that its optimal
for human and machine readability is a good goal as well. JSON is a good format and perhaps
there are other opinions about using it for logging but nevertheless its not about json for logging
it more about “art of logging”

1 Like

I few things I’ve learned running productions systems:

  1. always handle or log errors. Even if you think it’s unnecessary to check an error return code, do it anyway. This will save you untold grief when things go wrong.
  2. build into applications tools for processing the log files it generates – essentially ways to filter the log files to quickly find what you are looking for. Why not for every application add command line flags where the same application can be used to process its log files. Then the tooling to process the log files and the code that generates the log files are in the same place, and it is easy to keep in sync.

I’ve not done #2 yet much, but I need to – especially with edge devices that are connected via low bandwidth Cat-M modems – we can’t afford the bandwidth to send all the logs to a central place, so we end up ssh’ing into these devices and looking at logs. But this entire process could be automated so it could be done remotely.