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); } }
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); } }
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); } }