I am doing production support, relying much on log to troubleshoot. I found that the log information is quite messy for now.
Could you provide the best practice or guide to write log information?
BTW: we're using log4Net. Do you have any suggestion on alternative library?
Thanks.
Ideally, your log messages should include details of When, What, Where, Who, and some indication of how serious the event that triggered the message was.
I'd second the advice gave @Oded in keeping the messages tidy. For the routine stuff, date & time, log level, error code, I'd try to format them to be a fixed width, and put them at the start. It makes scanning the logs much easier.
As regards good guides on log message formatting, the only thing I have come across is chapter 17, of the book 'Release It!': http://www.pragprog.com/titles/mnee/release-it A lot of the above advice is based on that.
ELMAH is a very good logging library and not a bad alternative to log4net.
In regards to the formatting of your logs (you say the information is "messy", though you don't explain exactly what that means) - make sure each entry is clearly separated from others and that it is formatted in a readable manner (spacing, linebreaks etc...).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With