Esempio n. 1
0
        public void OnException(ExceptionContext context)
        {
            HttpStatusCode actualResultCode;

            if (ErrorToResponseMap.GetFromActionProperties(context.ActionDescriptor.Properties, out var map) &&
                map.TryGetBinding(context.Exception.GetType(), out var binding))
            {
                actualResultCode = SetBoundResult(context, binding);
            }
            else
            {
                actualResultCode = SetErrorResult(context);
            }

            if ((int)actualResultCode >= 500)
            {
                _log.Error(context.Exception)
                .AndFactIs("response-code", actualResultCode)
                .AndFactIs(HttpTraceIdFact.Key, context.HttpContext.TraceIdentifier)
                .Write();
            }
            else if ((int)actualResultCode >= 400)
            {
                _log.Warning(context.Exception)
                .AndFactIs("response-code", actualResultCode)
                .AndFactIs(HttpTraceIdFact.Key, context.HttpContext.TraceIdentifier)
                .Write();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Begin DSL expression for warning log-event
        /// </summary>
        public static DslExpression Warning(this IDslLogger dslLogger, string message, Exception reasonException)
        {
            if (dslLogger == null)
            {
                throw new ArgumentNullException(nameof(dslLogger));
            }

            return(dslLogger.Warning(message).BecauseOf(reasonException));
        }
Esempio n. 3
0
 public DslExpression Warning(string message)
 {
     return(ApplyExtensions(_dsl.Warning(message)));
 }