tags:

views:

202

answers:

3

Windows, Firefox or Google Chrome all monitor usage statistics and analyze the crash reports are sent to them. I am thinking of implementing the same feature into my application.

Of course it's easy to litter an application with a lot of logging statement, but this is the approach that I want to avoid because I don't want my code to have too many cross cutting concern in a function. I am thinking about using AOP to do it, but before that I want to know how other people implement this feature first.

Anyone has any suggestion?

Clarification: I am working on desktop application, and doesn't involve any RDBMS

+1  A: 

In "Debugging .Net 2.0 Applications" John Robbins (of Wintellect) writes extensively about how to generate and debug crash reports (acutally windbg/SOS mini dumps). His Superassert class contains code to generate these. Be warned though - there is a lot of effort required to set this up properly: symbol servers, source servers as well as a good knowledge of VS2005 and windbg. His book, however, guides you through the process.

Regarding usage statistics, I have often tied this into authorisation, i.e. has a user the right to carry out a particular task. Overly simply put this could be a method like this (ApplicationActions is an enum):

public static bool HasPermission( ApplicationActions action )
{
    // Validate user has permission.
    // Log request and result.
}

This method could be added to a singleton SercurityService class. As I said this is overly simple but should indicate the sort of service I have in mind.

ng5000
A: 

I would take a quick look at the Logging Application Block that is part of the Enterprise Library. It provided a large number of the things you require, and is well maintained. Check out some of the scenarios and samples available, I think you will find them to your liking.

http://msdn.microsoft.com/en-us/library/cc309506.aspx

Brian Rudolph
EL is rubbish, avoid it at all costs
Greg Dean
Wow, thats a fairly unsubstantiated claim. I'd agree that many of the application blocks are close to useless, but some have merit.
Brian Rudolph
+1  A: 

Joel had a blog article about something like this - his app(s) trap crashes and then contact his server with some set of details. I think he checks for duplicates and throws them out. It is a great system and I was impressed when I read it.

http://www.fogcreek.com/FogBugz/docs/30/UsingFogBUGZtoGetCrashRep.html

We did this at a place I was at that had a public server set up to receive data. I am not a db guy and have no servers I control on the public internets. My personal projects unfortunately do not have this great feature yet.

Tim