LA.NET [EN]

May 07

The ASP.NET May bits introduce some Diagnostic related classes that

try to give you some help in logging client exceptions. Dropping the ASP.NET Diagnostics control in an ASP.NET AJAX page adds a reference to PreviewDiagnostics.js file. This file has code that creates a Sys.Preview.DiagnosticsService object (of type Sys.Preview._DiagnosticsService). In theory, the object will automatically handle all errors that aren”t trapped by your code and then it”ll invoke a remote web service which is responsible for notifying the interested parties about that error.

I say in theory because after looking at the code, I think that it doesn”t work in the current release (at least, the web service method calling part isn”t really working). Again, I”m hopping to be wrong :,,)

After using Reflector, I”ve noticed that there”s a new class (DiagnosticsService) which is supposed to be the web service responsible for receinving the exception sent from the client side. I think that the idea is to build a service similar to the authentication/profile service. Unfortunately, i think that currently the WebServiceData class is only able to create authentication or profile web service instances maintained inside a dll. That being the case, it really looks like the web service call won”t really work (maybe that”s why they”ve left the client error callback method empty?).

If you really want to, you can create a local web service with the same name and redirect the methods call to the “real” service that is embedded in the dll. However, doing that won”t do any good because in the current version the class doesn”t do any logging: it just wraps the ExceptionInfo object it receives from the client and then it fires the event OnClientException (real weird name for an event, if you ask me; and I”m still not sure on what”s the purpose of firing an event when an exception is received). So, if you want to log the exception, build the web service and perform the logging yourself.

Besides the server control, the javascript client  class and the embedded web service, there”s still another interesting (hum…maybe promising is a better name for it!) class: DiagnosticsHandler. It seems like the idea is to have a handler that is able to generate some sort of info about the exceptions caught and sent back to the server. Again, the current version doesn”t have anything that lets us do more than speculate since the ProcessRequest method generates some static HTML which really doesn”t do anything useful.

In fact, it seems like the only working feature is the display client method which opens a page and prints the current exceptions maintained by the client object.

Even though i know these are just CTP bits, i”m not sure on what was the purpose of adding these features to these bits. I mean, they simply don”t work. Or did I forgot something?

[Update: after publishing the article, I”ve just noticed that there is a quickstarts page for the Future bits. Well, it”s kind of interesting that I”ve managed to spend 30 mins trying to figure out things when i could just have read the damn docs (mental note: next time, search for the docs before using Reflector! :)). Reading those docs do share some light on how to use diagnostics. I specially enjoyed the “having to wire the static event on the application start event after creating a dummy DiagnosticsService.asmx file”. If you ask me, I really don”t know why don”t dey define a basic “interface” for a web service. If i have to create a dummy asmx file, why not go all the way and build a web service that performs the logging?]

4 comments so far

  1. Jonathan Hawkins (jhawk)
    8:47 pm - 5-7-2007

    Hi luisabreu

    For the current CTP bits you need to do a little more work to get diagnostics to log on the server 1) add a DiagnosticsService.asmx to your web application that points to the DiagnosticsService class 2) add entries to your web.config to enable Diagnostics and 3) write a small amount of app code to log the diagnostics to a store (file, memory, database, etc) of your choice

    You can find a QuickStart at
    http://quickstarts.asp.net/Futures/services/doc/diagnostics.aspx that describes the steps.

    You can find sample code at: http://quickstarts.asp.net/Futures/util/srcview.aspx?path=~/services/samples/diagnostics/default.src

    Please email me on my blog at http://blogs.msdn.com/jhawk with feedback on the diagnostics service.

    jhawk

  2. Luis Abreu
    9:10 pm - 5-7-2007

    Hello Jonathan.
    yes, you”re correct. As you can see by the update, I”ve discovered it some time after posting the article. Unfortunately, i didn”t had the time to write it right away 🙁

    After looking at the sample code, i think that my biggest question is why don”t you follow the patterns you”re using with the authentication and profile services?

  3. Jonathan Hawkins (jhawk)
    7:50 pm - 5-9-2007

    Hi Luis

    The Diagnostics work is still in preview stage, so I thought we should get what we have out to customers and listen to the feedback. Yes, one of the areas for the future is to enable a similar model for exposing the diagnostics service as we currently do today for the authentication and profile service.

    A question for you: You currently have to write app code to log the diagnostics information. If we did something automatic what options you like and what should be the default? integrated with IIS health monitoring (Web Events) or log to text file or log to a database or integrated with System.Diagnostics trace listeners etc or ? I look forward to your feeedback.

    jhawk

  4. luisabreu
    9:20 pm - 5-9-2007

    Hello Jonathan!

    yeah, i”d really love that it would behave like the current services (authentication and profiles) provided by the current version of ASP.NET AJAX.

    regarding your second question, it”s a tricky one. I”ve played with the health monitoring system during the betas of ASP.NET (i”m assuming that we”re talking about the health monitoring services introduced by ASP.NET 2.0?). I really loved it. Not sure if many use it in their apps though. for instance, even though i really like the health monitoring services, the truth is that I”ve only used it in production code once (in the other cases, logging is performed through the logging application block or log4net). If you ask me, i think that in my case, i”ve been using text files and databases for diagnostics purposes.