ASP.NET Health Monitoring is one of the more under-hyped features of ASP.NET. It is a rich, flexible logging framework that can be used to log application events in a database, flat file, email, or custom source. However, JavaScript errors, since they occur on the client-side, do not get the benefits of this framework. Fortunately this can be fixed by linking the client to the server with a little Ajax. James Newton-King has posted a great solution to do just this in ASP.NET.
In this solution, a small script to capture errors from window.error is registered on the client. These errors are wrapped in XML and sent to the server via XmlHttp. On the server, an HttpHandler unwraps the XML and logs a Web Event for the exception- including browser information. Viola! Client-side errors in your application's event log. This is extremely useful for debugging problem scripts and alerting you to problems in your application you may otherwise miss.