views:

117

answers:

2

Hello all, I'm looking for a best practices checklist for instrumenting my code. Not so much what tools to use (I'm a System.Diagnostics.Trace fan myself) but just where you should put tracing statements in a "typical" application.

If you have a tip (or tips) can you please provide them here. Maybe distinguish stuff that you absolutely must include versus things that could potentially save your bacon.

+1  A: 

This P&P article, Measuring .NET Application Performance, outlines aspects of an application that can be logged and measured regrading performance monitoring and analysis.

Other areas worth considering for instrumentation are security auditing, error and exception logging, and reportable application events - such as when someone places an order, or when a new user registers.

cxfx
Walter
+1  A: 

I recently saw a demo of PostSharp at a code camp, and it appears to make instrumenting your application almost effortless. If you can accept that it uses IL weaving to do its magic, it could save significant effort (and better yet, keep your code clean).

The presenter (Michael Hall) suggested using PostSharp.Laos for simplicity and to avoid licensing restrictions.

TrueWill
That looks really nice. I like the use of attributes for this type of thing so that you don't end up with a whole lot of extra messy code to wade through.I'll look into this further!
Qwerty
@Qwerty: You can go further and avoid scattering attributes throughout your code. See the "Multicasting" section of this blog: http://doronsharp.spaces.live.com/Blog/cns!E19CE2289AB7F8C1!137.entry
TrueWill
...although Michael Hall suggested you might want to use a directive to exclude methods such as Dispose().
TrueWill