M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

Exception Recording

Exception handling and logging information contained in the exception object for later investigation and debugging purpose is a vital aspect of an application. This tutorial simply focuses on the exception logging implementation provided in M# framework. Recording exceptions in M# has been made very simple by exposing “RecordException” method, implemented in ApplicationEventManager static class explained in “Application Event Manager” tutorial.

“RecordException” method formats information contained in the exception object (including all inner exceptions) and logs it with the title of “Exception” in the database. Below are the overloads of “RecordException” method.

"Log.Record.Exceptions" app setting in web.config can also be used to turn on and off exception recording.

“ApplicationEventManager” class also contains a method “GetLatestExceptions”, which can be used to fetch all the logged exceptions from the database sorted by date.