/// <summary> /// Submit an exception to exceptron Servers. /// </summary> /// <param name="exception">Exception that is being reported</param> /// <param name="component" /// example="DataAccess, Configuration, Registration, etc." /// remarks="It is common to use the logger name that was used to log the exception as the component.">Component that experienced this exception.</param> /// <param name="severity">Severity of the exception being reported</param> /// <param name="message" /// example="Something went wrong while checking for application updates.">Any message that should be attached to this exceptions</param> /// <param name="userId" /// remarks="This Id does not have to be tied to the user's identity. /// You can use a system generated unique ID such as GUID. /// This field is used to report how many unique users are experiencing an error." /// example=" /// 62E5C8EF-0CA2-43AB-B278-FC6994F776ED /// [email protected] /// 26437 /// ">ID that will uniquely identify the user</param> /// <param name="httpContext"><see cref="System.Web.HttpContext"/> in which the exception occurred. If no <see cref="System.Web.HttpContext"/> is provided /// <see cref="ExceptronClient"/> will try to get the current <see cref="System.Web.HttpContext"/> from <see cref="System.Web.HttpContext.Current"/></param> /// <returns></returns> public ExceptionResponse SubmitException(Exception exception, string component, ExceptionSeverity severity = ExceptionSeverity.None, string message = null, string userId = null) { var exceptionData = new ExceptionData { Exception = exception, Component = component, Severity = severity, Message = message, UserId = userId }; return(SubmitException(exceptionData)); }
private void ValidateState(ExceptionData exceptionData) { if (string.IsNullOrEmpty(Configuration.ApiKey)) { throw new InvalidOperationException("ApiKey has not been provided for this client."); } if (exceptionData == null) { throw new ArgumentNullException("exceptionData"); } if (exceptionData.Exception == null) { throw new ArgumentException("ExceptionData.Exception Cannot be null.", "exceptionData"); } }
/// <summary> /// Submit an exception to exceptron Servers. /// </summary> /// <param name="exceptionData">Exception data to be reported to the server</param> public ExceptionResponse SubmitException(ExceptionData exceptionData) { try { ValidateState(exceptionData); var report = new ExceptionReport(); report.ap = Configuration.ApiKey; report.dn = ClientName; report.dv = ClientVersion; report.aver = _applicationVersion; report.ext = exceptionData.Exception.GetType().FullName; report.stk = ConvertToFrames(exceptionData.Exception); report.exm = exceptionData.Exception.Message; report.cmp = exceptionData.Component; report.uid = exceptionData.UserId; report.msg = exceptionData.Message; report.sv = (int)exceptionData.Severity; report.fv = _maxFrameworkVersion; report.ft = FrameworkType; SetEnviromentInfo(report); var exceptionResponse = RestClient.Put <ExceptionResponse>(Configuration.Host, report); exceptionData.Exception.Data["et"] = exceptionResponse.RefId; return(exceptionResponse); } catch (Exception e) { Trace.WriteLine("Unable to submit exception to exceptron. ", e.ToString()); if (Configuration.ThrowExceptions) { //throw; } return(new ExceptionResponse { Exception = e }); } }
protected override void Write(LogEventInfo logEvent) { if (logEvent == null || logEvent.Exception == null || logEvent.Exception.ExceptronShouldIgnore()) return; try { var exceptionData = new ExceptionData { Exception = logEvent.Exception, Component = logEvent.LoggerName, Message = logEvent.FormattedMessage, }; if (UserId != null) { exceptionData.UserId = UserId.Render(logEvent); } if (logEvent.Level <= LogLevel.Info) { exceptionData.Severity = ExceptionSeverity.None; } else if (logEvent.Level <= LogLevel.Warn) { exceptionData.Severity = ExceptionSeverity.Warning; } else if (logEvent.Level <= LogLevel.Error) { exceptionData.Severity = ExceptionSeverity.Error; } else if (logEvent.Level <= LogLevel.Fatal) { exceptionData.Severity = ExceptionSeverity.Fatal; } ExceptronClient.SubmitException(exceptionData); } catch (Exception e) { InternalLogger.Warn("Unable to report exception. {0}", e); } }
private void ValidateState(ExceptionData exceptionData) { if (string.IsNullOrEmpty(Configuration.ApiKey)) throw new InvalidOperationException("ApiKey has not been provided for this client."); if (exceptionData == null) throw new ArgumentNullException("exceptionData"); if (exceptionData.Exception == null) throw new ArgumentException("ExceptionData.Exception Cannot be null.", "exceptionData"); }
/// <summary> /// Submit an exception to exceptron Servers. /// </summary> /// <param name="exceptionData">Exception data to be reported to the server</param> public ExceptionResponse SubmitException(ExceptionData exceptionData) { try { ValidateState(exceptionData); var report = new ExceptionReport(); report.ap = Configuration.ApiKey; report.dn = ClientName; report.dv = ClientVersion; report.aver = _applicationVersion; report.ext = exceptionData.Exception.GetType().FullName; report.stk = ConvertToFrames(exceptionData.Exception); report.exm = exceptionData.Exception.Message; report.cmp = exceptionData.Component; report.uid = exceptionData.UserId; report.msg = exceptionData.Message; report.sv = (int)exceptionData.Severity; report.fv = _maxFrameworkVersion; report.ft = FrameworkType; SetEnviromentInfo(report); var exceptionResponse = RestClient.Put<ExceptionResponse>(Configuration.Host, report); exceptionData.Exception.Data["et"] = exceptionResponse.RefId; return exceptionResponse; } catch (Exception e) { Trace.WriteLine("Unable to submit exception to exceptron. ", e.ToString()); if (Configuration.ThrowExceptions) { //throw; } return new ExceptionResponse { Exception = e }; } }
/// <summary> /// Submit an exception to exceptron Servers. /// </summary> /// <param name="exception">Exception that is being reported</param> /// <param name="component" /// example="DataAccess, Configuration, Registration, etc." /// remarks="It is common to use the logger name that was used to log the exception as the component.">Component that experienced this exception.</param> /// <param name="severity">Severity of the exception being reported</param> /// <param name="message" /// example="Something went wrong while checking for application updates.">Any message that should be attached to this exceptions</param> /// <param name="userId" /// remarks="This Id does not have to be tied to the user's identity. /// You can use a system generated unique ID such as GUID. /// This field is used to report how many unique users are experiencing an error." /// example=" /// 62E5C8EF-0CA2-43AB-B278-FC6994F776ED /// [email protected] /// 26437 /// ">ID that will uniquely identify the user</param> /// <param name="httpContext"><see cref="System.Web.HttpContext"/> in which the exception occurred. If no <see cref="System.Web.HttpContext"/> is provided /// <see cref="ExceptronClient"/> will try to get the current <see cref="System.Web.HttpContext"/> from <see cref="System.Web.HttpContext.Current"/></param> /// <returns></returns> public ExceptionResponse SubmitException(Exception exception, string component, ExceptionSeverity severity = ExceptionSeverity.None, string message = null, string userId = null) { var exceptionData = new ExceptionData { Exception = exception, Component = component, Severity = severity, Message = message, UserId = userId }; return SubmitException(exceptionData); }