I am not about to talk about logging visits and tracing users, but rather write log files.

Adding logging functions while you are writing a new software is really boring. It is one of those things that while you’re writing the software you don’t feel the need and think it will never be of any use.
Unfortunately softwares always have a flaw somewhere and users, for some reason, tend to do something that you hadn’t predicted.
When I started to write software I used to write only a few lines of logs here and there, just because someone told me I should do it.
Now my softwares are FULL of logs, almost any single action has a possible line of log. Of course I set many different levels of log, but when a new application goes online, I always have the logs set to the maximum. I want to see what happens and be able to trace it in the first days online.
I learnt the importance of logging where a client wanted me to explain why one of his customers was complaining and we could not find what hadn’t worked properly. It has been really hard and basically we did not have an answer, but that day I decided that I wanted to have an answer the next time that this would have happened.

Logging is the only way you have to discover is something went wrong, what the user did to make your software crash or fail. It is REALLY important in my opinion. You should not only write logs, but you should also make sure that the logs you write will be useful. This is not simple, if you don’t know the problem, you can’t be able to write the logs that will be useful, so you should try to image what could go wrong and first of all make sure your software will “fail gracefully” and then you should try to log something that should be useful to replicate the problem and possibly solve it.

These are my two cents for a better programmer. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s