private void LogException(Error error, Exception exception) { var logMessage = new ExceptionLogMessage { Error = error, ExceptionInfo = exception.ToString() }; if (_logSettings.LogExceptions) { logMessage.Exception = exception; } var logAsJson = JsonConvert.SerializeObject(logMessage, _options?.Value?.SerializerSettings ?? new JsonSerializerSettings()); if (error.Status >= 500 && error.Status <= 599) { _logger?.LogError(logAsJson); } else if (error.Status >= 400 && error.Status <= 499) { _logger?.LogDebug(logAsJson); } else { _logger?.LogInformation(logAsJson); } }
public void LogException(ExceptionLogMessage entry) { if (ConfigItems.SendErrorEmails) { } }
public static void Exception <T>(T ex) where T : Exception { // GC.SuppressFinalize(ex); var message = new ExceptionLogMessage(typeof(T).FullName, ex.Message, ex.StackTrace); Post(message); // GC.ReRegisterForFinalize(ex); }
/// <summary> /// Writes to the log event with an exception, encoding its stack trace. /// </summary> /// <param name="ex">The <see cref="System.Exception"/> object to create the <see cref="LogMessage"/> from.</param> public static void Exception(Exception ex) { if (ex == null) { return; } var message = new ExceptionLogMessage(ex.GetType().Name, ex.Message, ex.StackTrace); OnOutput(message); }
public static void Exception(Exception ex) { var message = new ExceptionLogMessage(ex); Post(message); }