Ok, sorry for the extremely poor Shakespearian reference, but its late and I've drank one to many this evening =). Anyway, as I'm flipping through my code, adding logging information via Log4Net, I wonder: Am I getting carried away? I guess I'm really looking for advice from people out there with experience writing logging code; just how much logging code is enough.
I find myself wanting to write a log.info line for every executable line of code I have; and I know that's not right. So here is the formula I'm currently using:
- Create a logging entry at the beginning of each method that reflects the name of the method (e.g. _log.Info("Class::Method(hashcode)");
- Create a logging entry for each "logical" unit of work (e.g. I can't really define what this is, but I know it when I see it in my code)
- Create a logging entry for each error caught or thrown (e.g. _log.Error("Method puked", ex);)
I'll be the first to admit, this is a pretty rudimentary approach, but at this point, I'm not sure of a better one. The Log4Net documentation is excellent in terms of how to use Log4Net, but it doesn't describe a logging strategy.
So for that logging strategy I'm turning to you, the .NET blogging community. How do you use Log4Net in your apps? Do you following a particular strategy/formula. If you do please let me know, I'm sure there's a better way!
[Listening to: A rerun of The Practice : my wife talk about our upcoming trip to wine country : my dogs playing with their food]