Пример #1
0
 protected void WriteExceptionData(RequestLogger logger, string path, Exception ex)
 {
     if (ex.Data != null)
     {
         foreach (DictionaryEntry entry in ex.Data)
         {
             try
             {
                 logger.WithData(path + "." + Convert.ToString(entry.Key), Convert.ToString(entry.Value));
             }
             catch (Exception) { }
         }
     }
     if (ex.InnerException != null)
     {
         WriteExceptionData(logger, path + ".Inner", ex.InnerException);
     }
     if (ex is AggregateException agex)
     {
         var i = 0;
         foreach (var subex in agex.InnerExceptions)
         {
             WriteExceptionData(logger, path + ".Inner[" + i + "]", subex);
             i++;
         }
     }
 }
 public override void PostInvoke(HttpContext context, RequestLogger requestLogger)
 {
     if (requestLogger.DurationMs > 5000)
     {
         if (requestLogger.StoreLog == null)
         {
             requestLogger.StoreLog = true;
         }
         requestLogger.SetMessage(LogAspect.Timing.Name, false, null);
     }
 }
Пример #3
0
 public override void PostInvoke(HttpContext context, RequestLogger requestLogger)
 {
     if (context.Response.StatusCode == 404)
     {
         if (requestLogger.StoreLog == null)
         {
             requestLogger.StoreLog = true;
         }
         requestLogger.SetMessage(LogAspect.NotFound.Name, false, null);
     }
 }
Пример #4
0
 public async Task InvokeAsync(HttpContext context, RequestLogger requestLogger)
 {
     PreInvoke(context, requestLogger);
     try
     {
         await _next(context);
     }
     finally
     {
         PostInvoke(context, requestLogger);
     }
 }
Пример #5
0
        public override void PostInvoke(HttpContext context, RequestLogger requestLogger)
        {
            // Try and retrieve the error from the ExceptionHandler middleware
            var exceptionDetails = context.Features.Get <IExceptionHandlerFeature>();
            var ex = exceptionDetails?.Error;

            if (ex != null)
            {
                if (requestLogger.StoreLog == null)
                {
                    requestLogger.StoreLog = true;
                }
                var aspect = (ex is SecurityException) ? LogAspect.Security : LogAspect.Error;
                requestLogger.SetMessage(aspect.Name, true, ex.Message);
                requestLogger.WriteLine(ex.ToString());
                WriteExceptionData(requestLogger, "Ex", ex);
            }
        }
Пример #6
0
 public abstract void PostInvoke(HttpContext context, RequestLogger requestLogger);
Пример #7
0
 public override void PostInvoke(HttpContext context, RequestLogger requestLogger)
 {
     requestLogger.RequestEnded(context);
 }
Пример #8
0
 public override void PreInvoke(HttpContext context, RequestLogger requestLogger)
 {
     requestLogger.RequestStarted();
 }
Пример #9
0
 public override void PreInvoke(HttpContext context, RequestLogger requestLogger)
 {
 }