I remember once in college, during my first big project in C, a friend came up to me with a technical question. He was having problems with a socket not getting connected to another socket. I asked to see the his application’s log file. He showed it to me.
I was very blunt with my reaction: “That log file is a piece of crap”, I said. Immediately, I suggested he improved his log file and so he did. Luckily, I did that at the beginning of the project; which was very helpful to him. At the end of the trimester, we both passed that class with our teams.
Some people think that log files are useless; I don’t. I think log files are very useful to find problems among different environments. For instance, now we are having a problem with a web application deployed in production. And what I see in the log file is something like this:
Processing EntityController#details (for 77.6.24.163 at 2008-11-25 21:12:22) [GET]
Session ID: c73f95a286afeee5b27e58774ed63451
Parameters: {“action”=>”details”, “id”=>”d225-Batata_Dogs-P20323″, “controller”=>”Entity”}
Spoot!
Rendering within layouts/redbox
Rendering entity/details
Completed in 0.84559 (1 reqs/sec) | Rendering: 0.00313 (0%) | DB: 0.13164 (15%) | 200 OK [http://www.aycron.com/entity/details/d225-Batata_Dogs-P20323]
Yes, a big piece of spoot!
I didn’t write the line which creates such a poor log:
logger.info(“Spoot!”);
But now I have to deal with it. Obviously, something went wrong during execution, so why not communicate it? I don’t understand why some developers, in general, don’t write useful log statements, like:
logger.info(“The entity you are looking for could not be found or is not visible to you”);
Generally speaking, most of the time spent on a successful project will always get spent on maintenance. We, as developers, should write code that is easy to maintain (not only for our sake, but for other developers’ sake).
That way, once there is a problem (and there will always be problems), we know how to respond. That way, we will produce high-quality code; and the next guy won’t curse our family when he/she needs to maintain it.
Is it too much to ask?