Monday, June 22, 2009

I've written that I think just about any logging can be useful, and that I disagree with removing logging just because they clutter the logs, which is something some of my coworkers have done from time to time. I don't disagree with their removal of log messages in general as much as I disagree with their removal of the logging of stack traces, though. Whenever I have to debug something and run into an exception with an unlogged stack trace, I restore the logging of the stack trace of just about every exception that is caught in that file. Back to the topic of just about any logging being useful, though.

A few years ago, I used the logs to do quick and dirty profiling, since each log message included the thread and a timestamp to the millisecond. By looking at the time differentials between the log messages, I could see what code segments were taking the most time. In that case, most of the time spent waiting for HTTP responses, which was actually rather predictable.

The point remains, which is that just about any log message could contain information that would turn out to be useful in some unforeseen future situation.

I prefer my log messages to contain information that is likely to be useful, so that's why log statements that I write tend to be like

log("variable1="+variable1+",variable2="+variable2+",variable3="+variable3);

and don't have the verbiage that log statements written by other people have.

No comments:

Post a Comment