To build successful and flexible applications that can be maintained and supported easily, you must adopt an appropriate strategy for exception management. You must design your system to ensure that it is capable of the following:
- Detecting exceptions.
- Logging and reporting information.
- Generating events that can be monitored externally to assist system operation.
Spending the time at the beginning to design a clear and consistent exception management system frees you from having to piece one together during development, or worse still, from having to retrofit exception handling back into an existing code base.
An exception management system should be well encapsulated and should abstract the details of logging and reporting from the application's business logic. It should also be capable of generating metrics that can be monitored by operators to provide an insight into the current health and status of the application. This helps to create an application that can quickly and accurately notify operators of any problems it is experiencing, and can provide valuable information to assist developers and support services with problem resolution.
http://msdn2.microsoft.com/en-us/library/ms954599.aspx
Exception Management in AxCMS.net
As base for the Exception Management the Axinom Enterprise CMS uses the Exception Management Application Block by Microsoft. Further details at Microsoft Developer Network (msdn.microsoft.com).
Should an exception occur and not be intercepted, the user receives a general error page (error.htm) and the exception information is documented (“published”).
Configuration of the Exception-Management:
Several ExceptionPublishers are available to you, in addition you can develop (have them developed) your own ExceptionPublishers. Standard setting is ExceptionPublisherFile.
<configSections>
<section
name="exceptionManagement"
type="Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandler,
Microsoft.ApplicationBlocks.ExceptionManagement" />
</configSections>
<exceptionManagement>
<publisher
mode="on"
overwrite="false"
assembly="Axinom.Framework"
type="Axinom.Framework.Exception.ExceptionPublisherFile"
File="c:\temp\exceptions.txt"
/>
<publisher
mode="off"
assembly="Axinom.Framework"
type="Axinom.Framework.Exception.ExceptionPublisherMail"
operator="exceptions.dev.CMSDemo@yourCompany.com"
From="ExceptionManagement@yourCompany.com"
/>
<publisher
mode="off"
assembly="Microsoft.ApplicationBlocks.ExceptionManagement"
type="Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher"
/>
</exceptionManagement>
| Name |
Producer |
Target |
Description |
| ExceptionPublisherFile |
Axinom |
File |
Only the last Exception will be stored. Parameter: File Note: Write access for the ASPNET-User for the mentioned file. |
| ExceptionPublisherMail |
Axinom |
E-Mail |
An E-Mail will be sent per exception to an operator. Parameter: Operator, Subject, From Note: SmtpServer has to be set up correctly at AppSettings |
| DefaultPublisher |
Microsoft |
EventLog |
Parameter: logName, applicationName Note: Write access for EventLog. Are usually assigned by CMS-Installer. If not, you can do it manually with installutil.exe. You will find an example in the CMS at installation\ConfigureExceptionPublisher.bat. |
| CustomPublisher |
|
|
Any required method to transfer exceptions to the developers I.e. save in a data base. |
| ExceptionPublisher |
Axinom |
Mail/File
|
Obsolete, not any longer supported. |
With on/off the respective ExceptionPublisher can be switched on and off.
If a Messaging System like Microsoft Exchange is used, we recommend the ExceptionPublisherMail and a Public Folder as address for the exceptions.
Troubleshoot
If the exceptions file was not stored:
Make sure that the ASPNET-User has write access for the mentioned file.
According to the web.config settings only the last Exception might be stored, to avoid that add overwrite="false"
If the exception mail was not sent:
Make sure that the SmtpServer has set up correctly at AppSettings
If your application throws a security exception, then something in your exception management is not configured well. AxCMS.net then tries to write exception in Event Log. To be able to do this, it must be allowed. Please run following command in commandline to allow writing in EventLog:
%WINDIR%\Microsoft.NET\Framework\v1.1.4322\installutil C:\Projects\AxCMS_Sample\Components\Components\Microsoft.ApplicationBlocks.ExceptionManagement.dll
Please have a look in our forum too...
Use exception management in your AxCMS.net related application (importer, create application)
To be able to use our mail sending exception management you have to init smtp server in your application:
System.Web.Mail.SmtpMail.SmtpServer = CMSConfigurationSettings.SmtpServer;