Click here to Skip to main content
12,403,796 members (68,179 online)
Click here to Skip to main content

Stats

58.1K views
545 downloads
22 bookmarked
Posted

Handling Error Centrally in a SharePoint Application

, 20 May 2008 CPOL
An article on handling errors centrally in a SharePoint application, using IHttpModule.
<configuration>

	<configSections>
		<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
	</configSections>

	<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
		<listeners>
			<add fileName="C:\MySharePointSite.log" header="----------------------------------------"
						 footer="----------------------------------------"
						 formatter="Text Formatter"
						 listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
						 traceOutputOptions="None"
						 type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
						 name="FlatFile TraceListener" />
		</listeners>
		<formatters>
			<add template=	"Code:{title}&#xD;&#xA; 	Timestamp: {timestamp}&#xD;&#xA; 
		    Message: {message}&#xD;&#xA; 				Category: {category}&#xD;&#xA; 
		    Priority: {priority}&#xD;&#xA;				EventId: {eventid}&#xD;&#xA;
			Severity: {severity}&#xD;&#xA;				Machine: {machine}&#xD;&#xA;
			Application Domain: {appDomain}&#xD;&#xA;	Process Id: {processId}&#xD;&#xA;
			Process Name: {processName}&#xD;&#xA;Win32 	Thread Id: {win32ThreadId}&#xD;&#xA;
			Thread Name: {threadName}&#xD;&#xA;		
			Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
				  name="Text Formatter" />
		</formatters>
		<categorySources>
			<add switchValue="All" name="General">
				<listeners>
					<add name="FlatFile TraceListener" />
				</listeners>
			</add>
		</categorySources>
		<specialSources>
			<allEvents switchValue="All" name="All Events" />
			<notProcessed switchValue="All" name="Unprocessed Category" />
			<errors switchValue="All" name="Logging Errors &amp; Warnings" />
		</specialSources>
	</loggingConfiguration>

</configuration>


<system.web>
	<httpModules>
		<add name="MyErrorHandler" type="CentralErrorHandler.ErrorModule, CentralErrorHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=06a3e095a0c5fc38 " />
	</httpModules>
</system.web>


<appSettings>
	<add key="CustomErrorPagePath" value="http://MySharePointSite/MyErrorHandler.aspx" />
</appSettings>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Anupam Ranku
Software Developer (Senior) Gen-i, Australia
Australia Australia
Expertise area: ASP.NET, C#, Microsoft Office SharePoint 2010 & 2007, Web Service, Windows-based Applications etc.

Blog: http://mydevdiary.blogspot.com/

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 20 May 2008
Article Copyright 2008 by Anupam Ranku
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid