1

I'm working on a website that uses JQuery on the client and ASP.NET/C# and PageMethods on the server.

I'm looking for some suggestions for logging JavaScript errors on the server.

My plan is to have some general-purpose PageMethods in my base page, and if an error occurs in a try/catch block in my JQuery code, I'll call the PageMethod and pass up the function name, user context, and other relevant params (like JSON strings, variables, etc).

Obviously, I'll only be able to do this for errors that are caught in a try/catch block.

A similar question was posed here but that was more than 6 months ago.

I'm considering both Log4Net and native .NET logging capabilities on the server.

Community
  • 1
  • 1
Armchair Bronco
  • 2,367
  • 4
  • 31
  • 44

1 Answers1

1

I am not a big fan of using log4net and other tools when you can do it using simple methods like an async call to the server.

what I would suggest is you create a handler to handle all your errors in JS and make an async call to it using jquery.ajax () (http://api.jquery.com/jQuery.ajax/) and at the server you handle these errors and handle it with your error logger on server.

Does that sound good?

You should avoid learning new tools and adding to the complication cos if suddenly there are any errors you are now dependent on the support for that tool.

Baz1nga
  • 15,485
  • 3
  • 35
  • 61
  • I've heard a lot of similar comments on other threads about Log4Net. The feeling is that while this is a good platform for logging, it doesn't really offer features that are orders of magnitude more powerful than the native .NET logging pieces. – Armchair Bronco Dec 28 '10 at 06:43
  • I'll accept this answer because my co-founder ended up writing his own mega-simple logging class based on some articles he read. Like you, he didn't want to take a dependency on a heavy library when there are already existing library in .NET that will give use a big slice of the same functionality. – Armchair Bronco Jun 07 '11 at 02:41