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);
            }
        }
示例#2
0
        public void LogException(ExceptionLogMessage entry)
        {
            if (ConfigItems.SendErrorEmails)
            {

            }
        }
示例#3
0
        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);
        }
示例#4
0
        /// <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);
        }
示例#5
0
        public static void Exception(Exception ex)
        {
            var message = new ExceptionLogMessage(ex);

            Post(message);
        }