Share via


What do the logs say? (posted by Aaron)

A few years ago when I started in my current job my group ran into a situation on an internal system (that we had written) where it wasn’t entirely clear what had actually happened.  We had data in the database that just didn’t seem to match up with what we were expecting.  It was puzzling, but we needed answers.  My manager came to me and below is a quick recap of that conversation:

Manager: “Well, what do the logs say?” 
A puzzled look came across my face…
Me:  “Logs?” (doesn’t he know that we never talked about including any logging?) 
Manager:  “Yeah logs.  Don’t we log everything in the database that takes place so we can track it back to who did what?” 
Groan.  
Me:  “No, we don’t.”

Since that time I’ve learned the importance of logging just about everything that happens in the applications I write.  I can probably only count a handful of times where I’ve actually needed to reference that data, but each and every time I’ve needed it it’s been a life saver. 

When something goes wrong a user’s first inclination is to blame the application that they were interacting with.  Without the logs, it’s pretty difficult to defend the application because the user is in complete control of the “story” they tell.  Now don’t get me wrong, I’m not suggesting that everything needs to be logged, but I do think it’s important to analyze any application you’re writing and make sure you have a good story in place for logging.  You probably won’t need the data 99.9% of the time, but when you do need it, it’s invaluable.

Aaron