Esempio n. 1
0
    /// <summary>
    /// Writes logging event to the log target.
    /// </summary>
    /// <param name="logEvent">Logging event to be written out.</param>
    protected override void Write(LogEventInfo logEvent)
    {
        var notice = (logEvent.Exception != null) ? SharpbrakeClient.BuildNotice(logEvent.Exception) : SharpbrakeClient.BuildNotice(logEvent.ToAirBrakeError());

        if (logEvent.Exception != null && logEvent.Exception.InnerException != null)
            notice.Error.Backtrace = GetBackTraceLines(logEvent.Exception.InnerException, 1).ToArray();
        // Override the notice message so we have the full exception
        // message, including the messages of the inner exceptions.
        // Also, include the log message, if it is set.
        string exceptionMessage = BuildExceptionMessage(logEvent.Exception);
        notice.Error.Message = !string.IsNullOrEmpty(logEvent.FormattedMessage) ? logEvent.FormattedMessage + " " + exceptionMessage : exceptionMessage;

        this.SharpbrakeClient.Send(notice);
    }
Esempio n. 2
0
        /// <summary>
        /// Writes logging event to the log target.
        /// </summary>
        /// <param name="logEvent">Logging event to be written out.</param>
        protected override void Write(LogEventInfo logEvent)
        {
            var notice = (logEvent.Exception != null) ? SharpbrakeClient.BuildNotice(logEvent.Exception) : SharpbrakeClient.BuildNotice(logEvent.ToAirBrakeError());

            if (logEvent.Exception != null && logEvent.Exception.InnerException != null)
            {
                notice.Error.Backtrace = GetBackTraceLines(logEvent.Exception.InnerException, 1).ToArray();
            }
            // Override the notice message so we have the full exception
            // message, including the messages of the inner exceptions.
            // Also, include the log message, if it is set.
            string exceptionMessage = BuildExceptionMessage(logEvent.Exception);

            notice.Error.Message = !string.IsNullOrEmpty(logEvent.FormattedMessage) ? logEvent.FormattedMessage + " " + exceptionMessage : exceptionMessage;

            this.SharpbrakeClient.Send(notice);
        }