Showing the changes to Source/Libraries/GSF.Core/ErrorManagement/ErrorModule.cs (1 of 628 files). Show all
Unified · Split
| @@ -0,0 +1,397 @@ | ||
| 1 | +//******************************************************************************************************* | |
| 2 | +// ErrorModule.cs - Gbtc | |
| 3 | +// | |
| 4 | +// Tennessee Valley Authority, 2009 | |
| 5 | +// No copyright is claimed pursuant to 17 USC § 105. All Other Rights Reserved. | |
| 6 | +// | |
| 7 | +// This software is made freely available under the TVA Open Source Agreement (see below). | |
| 8 | +// | |
| 9 | +// Code Modification History: | |
| 10 | +// ----------------------------------------------------------------------------------------------------- | |
| 11 | +// 04/17/2007 - Pinal C. Patel | |
| 12 | +// Generated original version of source code. | |
| 13 | +// 09/13/2007 - Darrell Zuercher | |
| 14 | +// Edited code comments. | |
| 15 | +// 09/24/2008 - Pinal C. Patel | |
| 16 | +// Converted code to C#. | |
| 17 | +// 10/17/2008 - Pinal C. Patel | |
| 18 | +// Edited code comments. | |
| 19 | +// 08/05/2009 - Josh L. Patterson | |
| 20 | +// Edited Comments. | |
| 21 | +// 09/14/2009 - Stephen C. Wills | |
| 22 | +// Added new header and license agreement. | |
| 23 | +// | |
| 24 | +//******************************************************************************************************* | |
| 25 | + | |
| 26 | +#region [ TVA Open Source Agreement ] | |
| 27 | +/* | |
| 28 | + | |
| 29 | + THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE,REPRODUCTION, DISTRIBUTION, | |
| 30 | + MODIFICATION AND REDISTRIBUTION OF CERTAIN COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE | |
| 31 | + TENNESSEE VALLEY AUTHORITY, A CORPORATE AGENCY AND INSTRUMENTALITY OF THE UNITED STATES GOVERNMENT | |
| 32 | + ("GOVERNMENT AGENCY"). GOVERNMENT AGENCY IS AN INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT | |
| 33 | + DISTRIBUTIONS OR REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES, DISTRIBUTES, | |
| 34 | + MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED HEREIN, OR ANY PART THEREOF, IS, BY THAT | |
| 35 | + ACTION, ACCEPTING IN FULL THE RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT. | |
| 36 | + | |
| 37 | + Original Software Designation: openPDC | |
| 38 | + Original Software Title: The GSF Open Source Phasor Data Concentrator | |
| 39 | + User Registration Requested. Please Visit https://naspi.tva.com/Registration/ | |
| 40 | + Point of Contact for Original Software: J. Ritchie Carroll <mailto:jrcarrol@tva.gov> | |
| 41 | + | |
| 42 | + 1. DEFINITIONS | |
| 43 | + | |
| 44 | + A. "Contributor" means Government Agency, as the developer of the Original Software, and any entity | |
| 45 | + that makes a Modification. | |
| 46 | + | |
| 47 | + B. "Covered Patents" mean patent claims licensable by a Contributor that are necessarily infringed by | |
| 48 | + the use or sale of its Modification alone or when combined with the Subject Software. | |
| 49 | + | |
| 50 | + C. "Display" means the showing of a copy of the Subject Software, either directly or by means of an | |
| 51 | + image, or any other device. | |
| 52 | + | |
| 53 | + D. "Distribution" means conveyance or transfer of the Subject Software, regardless of means, to | |
| 54 | + another. | |
| 55 | + | |
| 56 | + E. "Larger Work" means computer software that combines Subject Software, or portions thereof, with | |
| 57 | + software separate from the Subject Software that is not governed by the terms of this Agreement. | |
| 58 | + | |
| 59 | + F. "Modification" means any alteration of, including addition to or deletion from, the substance or | |
| 60 | + structure of either the Original Software or Subject Software, and includes derivative works, as that | |
| 61 | + term is defined in the Copyright Statute, 17 USC § 101. However, the act of including Subject Software | |
| 62 | + as part of a Larger Work does not in and of itself constitute a Modification. | |
| 63 | + | |
| 64 | + G. "Original Software" means the computer software first released under this Agreement by Government | |
| 65 | + Agency entitled openPDC, including source code, object code and accompanying documentation, if any. | |
| 66 | + | |
| 67 | + H. "Recipient" means anyone who acquires the Subject Software under this Agreement, including all | |
| 68 | + Contributors. | |
| 69 | + | |
| 70 | + I. "Redistribution" means Distribution of the Subject Software after a Modification has been made. | |
| 71 | + | |
| 72 | + J. "Reproduction" means the making of a counterpart, image or copy of the Subject Software. | |
| 73 | + | |
| 74 | + K. "Sale" means the exchange of the Subject Software for money or equivalent value. | |
| 75 | + | |
| 76 | + L. "Subject Software" means the Original Software, Modifications, or any respective parts thereof. | |
| 77 | + | |
| 78 | + M. "Use" means the application or employment of the Subject Software for any purpose. | |
| 79 | + | |
| 80 | + 2. GRANT OF RIGHTS | |
| 81 | + | |
| 82 | + A. Under Non-Patent Rights: Subject to the terms and conditions of this Agreement, each Contributor, | |
| 83 | + with respect to its own contribution to the Subject Software, hereby grants to each Recipient a | |
| 84 | + non-exclusive, world-wide, royalty-free license to engage in the following activities pertaining to | |
| 85 | + the Subject Software: | |
| 86 | + | |
| 87 | + 1. Use | |
| 88 | + | |
| 89 | + 2. Distribution | |
| 90 | + | |
| 91 | + 3. Reproduction | |
| 92 | + | |
| 93 | + 4. Modification | |
| 94 | + | |
| 95 | + 5. Redistribution | |
| 96 | + | |
| 97 | + 6. Display | |
| 98 | + | |
| 99 | + B. Under Patent Rights: Subject to the terms and conditions of this Agreement, each Contributor, with | |
| 100 | + respect to its own contribution to the Subject Software, hereby grants to each Recipient under Covered | |
| 101 | + Patents a non-exclusive, world-wide, royalty-free license to engage in the following activities | |
| 102 | + pertaining to the Subject Software: | |
| 103 | + | |
| 104 | + 1. Use | |
| 105 | + | |
| 106 | + 2. Distribution | |
| 107 | + | |
| 108 | + 3. Reproduction | |
| 109 | + | |
| 110 | + 4. Sale | |
| 111 | + | |
| 112 | + 5. Offer for Sale | |
| 113 | + | |
| 114 | + C. The rights granted under Paragraph B. also apply to the combination of a Contributor's Modification | |
| 115 | + and the Subject Software if, at the time the Modification is added by the Contributor, the addition of | |
| 116 | + such Modification causes the combination to be covered by the Covered Patents. It does not apply to | |
| 117 | + any other combinations that include a Modification. | |
| 118 | + | |
| 119 | + D. The rights granted in Paragraphs A. and B. allow the Recipient to sublicense those same rights. | |
| 120 | + Such sublicense must be under the same terms and conditions of this Agreement. | |
| 121 | + | |
| 122 | + 3. OBLIGATIONS OF RECIPIENT | |
| 123 | + | |
| 124 | + A. Distribution or Redistribution of the Subject Software must be made under this Agreement except for | |
| 125 | + additions covered under paragraph 3H. | |
| 126 | + | |
| 127 | + 1. Whenever a Recipient distributes or redistributes the Subject Software, a copy of this Agreement | |
| 128 | + must be included with each copy of the Subject Software; and | |
| 129 | + | |
| 130 | + 2. If Recipient distributes or redistributes the Subject Software in any form other than source code, | |
| 131 | + Recipient must also make the source code freely available, and must provide with each copy of the | |
| 132 | + Subject Software information on how to obtain the source code in a reasonable manner on or through a | |
| 133 | + medium customarily used for software exchange. | |
| 134 | + | |
| 135 | + B. Each Recipient must ensure that the following copyright notice appears prominently in the Subject | |
| 136 | + Software: | |
| 137 | + | |
| 138 | + No copyright is claimed pursuant to 17 USC § 105. All Other Rights Reserved. | |
| 139 | + | |
| 140 | + C. Each Contributor must characterize its alteration of the Subject Software as a Modification and | |
| 141 | + must identify itself as the originator of its Modification in a manner that reasonably allows | |
| 142 | + subsequent Recipients to identify the originator of the Modification. In fulfillment of these | |
| 143 | + requirements, Contributor must include a file (e.g., a change log file) that describes the alterations | |
| 144 | + made and the date of the alterations, identifies Contributor as originator of the alterations, and | |
| 145 | + consents to characterization of the alterations as a Modification, for example, by including a | |
| 146 | + statement that the Modification is derived, directly or indirectly, from Original Software provided by | |
| 147 | + Government Agency. Once consent is granted, it may not thereafter be revoked. | |
| 148 | + | |
| 149 | + D. A Contributor may add its own copyright notice to the Subject Software. Once a copyright notice has | |
| 150 | + been added to the Subject Software, a Recipient may not remove it without the express permission of | |
| 151 | + the Contributor who added the notice. | |
| 152 | + | |
| 153 | + E. A Recipient may not make any representation in the Subject Software or in any promotional, | |
| 154 | + advertising or other material that may be construed as an endorsement by Government Agency or by any | |
| 155 | + prior Recipient of any product or service provided by Recipient, or that may seek to obtain commercial | |
| 156 | + advantage by the fact of Government Agency's or a prior Recipient's participation in this Agreement. | |
| 157 | + | |
| 158 | + F. In an effort to track usage and maintain accurate records of the Subject Software, each Recipient, | |
| 159 | + upon receipt of the Subject Software, is requested to register with Government Agency by visiting the | |
| 160 | + following website: https://naspi.tva.com/Registration/. Recipient's name and personal information | |
| 161 | + shall be used for statistical purposes only. Once a Recipient makes a Modification available, it is | |
| 162 | + requested that the Recipient inform Government Agency at the web site provided above how to access the | |
| 163 | + Modification. | |
| 164 | + | |
| 165 | + G. Each Contributor represents that that its Modification does not violate any existing agreements, | |
| 166 | + regulations, statutes or rules, and further that Contributor has sufficient rights to grant the rights | |
| 167 | + conveyed by this Agreement. | |
| 168 | + | |
| 169 | + H. A Recipient may choose to offer, and to charge a fee for, warranty, support, indemnity and/or | |
| 170 | + liability obligations to one or more other Recipients of the Subject Software. A Recipient may do so, | |
| 171 | + however, only on its own behalf and not on behalf of Government Agency or any other Recipient. Such a | |
| 172 | + Recipient must make it absolutely clear that any such warranty, support, indemnity and/or liability | |
| 173 | + obligation is offered by that Recipient alone. Further, such Recipient agrees to indemnify Government | |
| 174 | + Agency and every other Recipient for any liability incurred by them as a result of warranty, support, | |
| 175 | + indemnity and/or liability offered by such Recipient. | |
| 176 | + | |
| 177 | + I. A Recipient may create a Larger Work by combining Subject Software with separate software not | |
| 178 | + governed by the terms of this agreement and distribute the Larger Work as a single product. In such | |
| 179 | + case, the Recipient must make sure Subject Software, or portions thereof, included in the Larger Work | |
| 180 | + is subject to this Agreement. | |
| 181 | + | |
| 182 | + J. Notwithstanding any provisions contained herein, Recipient is hereby put on notice that export of | |
| 183 | + any goods or technical data from the United States may require some form of export license from the | |
| 184 | + U.S. Government. Failure to obtain necessary export licenses may result in criminal liability under | |
| 185 | + U.S. laws. Government Agency neither represents that a license shall not be required nor that, if | |
| 186 | + required, it shall be issued. Nothing granted herein provides any such export license. | |
| 187 | + | |
| 188 | + 4. DISCLAIMER OF WARRANTIES AND LIABILITIES; WAIVER AND INDEMNIFICATION | |
| 189 | + | |
| 190 | + A. No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER | |
| 191 | + EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT | |
| 192 | + SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 193 | + PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR | |
| 194 | + FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS | |
| 195 | + AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR | |
| 196 | + RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS | |
| 197 | + RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND | |
| 198 | + LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT | |
| 199 | + "AS IS." | |
| 200 | + | |
| 201 | + B. Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST GOVERNMENT AGENCY, ITS | |
| 202 | + AGENTS, EMPLOYEES, CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE | |
| 203 | + OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM | |
| 204 | + SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE | |
| 205 | + SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS GOVERNMENT AGENCY, ITS AGENTS, | |
| 206 | + EMPLOYEES, CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY | |
| 207 | + LAW. THE FOREGOING RELEASE AND INDEMNIFICATION SHALL APPLY EVEN IF THE LIABILITIES, DEMANDS, DAMAGES, | |
| 208 | + EXPENSES OR LOSSES ARE CAUSED, OCCASIONED, OR CONTRIBUTED TO BY THE NEGLIGENCE, SOLE OR CONCURRENT, OF | |
| 209 | + GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE | |
| 210 | + IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. | |
| 211 | + | |
| 212 | + 5. GENERAL TERMS | |
| 213 | + | |
| 214 | + A. Termination: This Agreement and the rights granted hereunder will terminate automatically if a | |
| 215 | + Recipient fails to comply with these terms and conditions, and fails to cure such noncompliance within | |
| 216 | + thirty (30) days of becoming aware of such noncompliance. Upon termination, a Recipient agrees to | |
| 217 | + immediately cease use and distribution of the Subject Software. All sublicenses to the Subject | |
| 218 | + Software properly granted by the breaching Recipient shall survive any such termination of this | |
| 219 | + Agreement. | |
| 220 | + | |
| 221 | + B. Severability: If any provision of this Agreement is invalid or unenforceable under applicable law, | |
| 222 | + it shall not affect the validity or enforceability of the remainder of the terms of this Agreement. | |
| 223 | + | |
| 224 | + C. Applicable Law: This Agreement shall be subject to United States federal law only for all purposes, | |
| 225 | + including, but not limited to, determining the validity of this Agreement, the meaning of its | |
| 226 | + provisions and the rights, obligations and remedies of the parties. | |
| 227 | + | |
| 228 | + D. Entire Understanding: This Agreement constitutes the entire understanding and agreement of the | |
| 229 | + parties relating to release of the Subject Software and may not be superseded, modified or amended | |
| 230 | + except by further written agreement duly executed by the parties. | |
| 231 | + | |
| 232 | + E. Binding Authority: By accepting and using the Subject Software under this Agreement, a Recipient | |
| 233 | + affirms its authority to bind the Recipient to all terms and conditions of this Agreement and that | |
| 234 | + Recipient hereby agrees to all terms and conditions herein. | |
| 235 | + | |
| 236 | + F. Point of Contact: Any Recipient contact with Government Agency is to be directed to the designated | |
| 237 | + representative as follows: J. Ritchie Carroll <mailto:jrcarrol@tva.gov>. | |
| 238 | + | |
| 239 | +*/ | |
| 240 | +#endregion | |
| 241 | + | |
| 242 | +using System.Diagnostics; | |
| 243 | +using System.Web; | |
| 244 | + | |
| 245 | +namespace GSF.ErrorManagement | |
| 246 | +{ | |
| 247 | + /// <summary> | |
| 248 | + /// Represents an HTTP module that can be used to handle exceptions globally in Web Sites and Web Services. | |
| 249 | + /// </summary> | |
| 250 | + /// <example> | |
| 251 | + /// Below is the config file entry required for enabling error handling using <see cref="ErrorModule"/>: | |
| 252 | + /// <code> | |
| 253 | + /// <![CDATA[ | |
| 254 | + /// <configuration> | |
| 255 | + /// <system.web> | |
| 256 | + /// <httpModules> | |
| 257 | + /// <add name="ErrorModule" type="GSF.ErrorManagement.ErrorModule, GSF.Core" /> | |
| 258 | + /// </httpModules> | |
| 259 | + /// </system.web> | |
| 260 | + /// </configuration> | |
| 261 | + /// ]]> | |
| 262 | + /// </code> | |
| 263 | + /// Below is the config file entry required for changing the settings of <see cref="ErrorModule.Logger"/>: | |
| 264 | + /// <code> | |
| 265 | + /// <![CDATA[ | |
| 266 | + /// <configuration> | |
| 267 | + /// <configSections> | |
| 268 | + /// <section name="categorizedSettings" type="GSF.Configuration.CategorizedSettingsSection, GSF.Core" /> | |
| 269 | + /// </configSections> | |
| 270 | + /// <categorizedSettings> | |
| 271 | + /// <errorLogger> | |
| 272 | + /// <add name="LogToUI" value="False" description="True if an encountered exception is to be logged to the User Interface; otherwise False." | |
| 273 | + /// encrypted="false" /> | |
| 274 | + /// <add name="LogToFile" value="True" description="True if an encountered exception is to be logged to a file; otherwise False." | |
| 275 | + /// encrypted="false" /> | |
| 276 | + /// <add name="LogToEmail" value="False" description="True if an email is to be sent to ContactEmail with the details of an encountered exception; otherwise False." | |
| 277 | + /// encrypted="false" /> | |
| 278 | + /// <add name="LogToEventLog" value="True" description="True if an encountered exception is to be logged to the Event Log; otherwise False." | |
| 279 | + /// encrypted="false" /> | |
| 280 | + /// <add name="LogToScreenshot" value="False" description="True if a screenshot is to be taken when an exception is encountered; otherwise False." | |
| 281 | + /// encrypted="false" /> | |
| 282 | + /// <add name="SmtpServer" value="smtp.email.com" description="Name of the SMTP server to be used for sending the email messages." | |
| 283 | + /// encrypted="false" /> | |
| 284 | + /// <add name="ContactEmail" value="" description="Comma-seperated list of recipient email addresses for the email message." | |
| 285 | + /// encrypted="false" /> | |
| 286 | + /// <add name="ContactName" value="" description="Name of the person that the end-user can contact when an exception is encountered." | |
| 287 | + /// encrypted="false" /> | |
| 288 | + /// <add name="ContactPhone" value="" description="Phone number of the person that the end-user can contact when an exception is encountered." | |
| 289 | + /// encrypted="false" /> | |
| 290 | + /// <add name="HandleUnhandledException" value="True" description="True if unhandled exceptions are to be handled automatically; otherwise False." | |
| 291 | + /// encrypted="false" /> | |
| 292 | + /// <add name="ExitOnUnhandledException" value="False" description="True if the application must exit when an unhandled exception is encountered; otherwise False." | |
| 293 | + /// encrypted="false" /> | |
| 294 | + /// </errorLogger> | |
| 295 | + /// </categorizedSettings> | |
| 296 | + /// </configuration> | |
| 297 | + /// ]]> | |
| 298 | + /// </code> | |
| 299 | + /// </example> | |
| 300 | + /// <seealso cref="ErrorLogger"/> | |
| 301 | + public class ErrorModule : IHttpModule | |
| 302 | + { | |
| 303 | + #region [ Members ] | |
| 304 | + | |
| 305 | + // Fields | |
| 306 | + private HttpApplication m_context; | |
| 307 | + | |
| 308 | + #endregion | |
| 309 | + | |
| 310 | + #region [ Methods ] | |
| 311 | + | |
| 312 | + /// <summary> | |
| 313 | + /// Initializes the <see cref="ErrorModule"/> and prepares it to handle requests. | |
| 314 | + /// </summary> | |
| 315 | + /// <param name="context">The <see cref="HttpApplication"/> to use for initialization.</param> | |
| 316 | + public void Init(HttpApplication context) | |
| 317 | + { | |
| 318 | + if (Logger.HandleUnhandledException && !Debugger.IsAttached) | |
| 319 | + { | |
| 320 | + m_context = context; // Save reference to the application. | |
| 321 | + m_context.Error += OnError; // Register to be notified for unhandled exceptions. | |
| 322 | + } | |
| 323 | + } | |
| 324 | + | |
| 325 | + /// <summary> | |
| 326 | + /// Disposes the resources (other than memory) used by the <see cref="ErrorModule"/>. | |
| 327 | + /// </summary> | |
| 328 | + public void Dispose() | |
| 329 | + { | |
| 330 | + if (Logger.HandleUnhandledException && !Debugger.IsAttached) | |
| 331 | + { | |
| 332 | + m_context.Error -= OnError; // Unregister from being notified for unhandled exceptions. | |
| 333 | + } | |
| 334 | + } | |
| 335 | + | |
| 336 | + private void OnError(object sender, System.EventArgs e) | |
| 337 | + { | |
| 338 | + // Log the last encountered exception. | |
| 339 | + Logger.Log(HttpContext.Current.Server.GetLastError()); | |
| 340 | + } | |
| 341 | + | |
| 342 | + #endregion | |
| 343 | + | |
| 344 | + #region [ Static ] | |
| 345 | + | |
| 346 | + private static ErrorLogger s_logger; | |
| 347 | + | |
| 348 | + static ErrorModule() | |
| 349 | + { | |
| 350 | + s_logger = new ErrorLogger(); | |
| 351 | + s_logger.PersistSettings = true; | |
| 352 | + s_logger.Initialize(); // Initialize error logger for use. | |
| 353 | + } | |
| 354 | + | |
| 355 | + /// <summary> | |
| 356 | + /// Gets the <see cref="ErrorLogger"/> object used by the <see cref="ErrorModule"/> object for logging exceptions. | |
| 357 | + /// </summary> | |
| 358 | + /// <remarks> | |
| 359 | + /// <see cref="Logger"/> property can be used for logging handled exception throughout the web application. | |
| 360 | + /// </remarks> | |
| 361 | + /// <example> | |
| 362 | + /// This example shows the use of <see cref="ErrorModule.Logger"/> for logging handled exception: | |
| 363 | + /// <code> | |
| 364 | + /// using System; | |
| 365 | + /// using GSF.ErrorManagement; | |
| 366 | + /// | |
| 367 | + /// namespace WebApp | |
| 368 | + /// { | |
| 369 | + /// public partial class _Default : System.Web.UI.Page | |
| 370 | + /// { | |
| 371 | + /// protected void Page_Load(object sender, EventArgs e) | |
| 372 | + /// { | |
| 373 | + /// try | |
| 374 | + /// { | |
| 375 | + /// string s = null; | |
| 376 | + /// s.ToCharArray(); // This will result in NullReferenceException. | |
| 377 | + /// } | |
| 378 | + /// catch (Exception ex) | |
| 379 | + /// { | |
| 380 | + /// ErrorModule.Logger.Log(ex); // Log the encountered exception. | |
| 381 | + /// } | |
| 382 | + /// } | |
| 383 | + /// } | |
| 384 | + /// } | |
| 385 | + /// </code> | |
| 386 | + /// </example> | |
| 387 | + public static ErrorLogger Logger | |
| 388 | + { | |
| 389 | + get | |
| 390 | + { | |
| 391 | + return s_logger; | |
| 392 | + } | |
| 393 | + } | |
| 394 | + | |
| 395 | + #endregion | |
| 396 | + } | |
| 397 | +} | |