예제 #1
0
        public static void LogException(HttpException exception)
        {
            if (exception != null)
            {
                Debug.Print(exception.ToString());
                Logger.Error(exception.ToString());

                try
                {
                    var error = new VLogServerSideError(exception);

                    VLogErrorCode weberrorcode = VLog.GetWebErrorCodeOrDefault(error.ErrorCode, VLogErrorTypes.ServerSideIIS);
                    if (weberrorcode != null && !weberrorcode.ExcludeFromLogging)
                    {
                        if (VLog.OnCommitExceptionToServerRepository != null)
                        {
                            VLog.OnCommitExceptionToServerRepository(error);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // IMPORTANT! We swallow any exception raised during the
                    // logging and send them out to the trace . The idea
                    // here is that logging of exceptions by itself should not
                    // be  critical to the overall operation of the application.
                    // The bad thing is that we catch ANY kind of exception,
                    // even system ones and potentially let them slip by.
                    Logger.Error(ex.ToString());
                    Debug.Print(ex.Message);
                }
            }
        }
예제 #2
0
		protected void Application_Error()
		{
			// Log ASP.NET errors (404, 500)
			HttpException exception = new HttpException(null, HttpContext.Current.Server.GetLastError());
			Log.Error("An ASP.NET based error occurred - ({0}) - {1}", 
						exception.GetHttpCode(),
						exception.ToString());
		}
 /// <summary>
 /// Sends back a response using the status code in the HttpException.
 /// The response body contains a details serialized in the responseFormat.
 /// If the HttpException.Data has a key named "details", its value is used as the response body.
 /// If there is no such key, HttpException.ToString() is used as the response body.
 /// </summary>
 /// <param name="httpException"></param>
 /// <param name="responseFormat"></param>
 public ResourceErrorActionResult(HttpException httpException, ContentType responseFormat) {
     this.statusCode = (HttpStatusCode)httpException.GetHttpCode();
     this.details = httpException.Data.Contains("details") ? httpException.Data["details"] : httpException.ToString();
     this.responseFormat = responseFormat;
 }