Ejemplo n.º 1
0
 public override void OnException(MethodExecutionArgs args)
 {
     //Suppress the current transaction to ensure exception is not rolled back
     using (var s = new TransactionScope(TransactionScopeOption.Suppress)) {
         //Log exception
         using (var exceptionLogContext = new ExceptionLogContext()) {
             exceptionLogContext.Set <ExceptionLogEntry>().Add(new ExceptionLogEntry(args.Exception));
             exceptionLogContext.SaveChanges();
         }
     }
 }
Ejemplo n.º 2
0
        private void LogException(System.Exception exception, RouteData routeData)
        {
            String controller = routeData.Values["controller"] as String;
            String action     = routeData.Values["action"] as String;

            ExceptionLogContext context = new ExceptionLogContext(exception)
            {
                Level      = LogLevel.Error,
                RequestUrl = HttpContext.Request.RawUrl,
                RefererUrl = (HttpContext.Request.UrlReferrer != null ? HttpContext.Request.UrlReferrer.ToString() : "null"),
                Controller = controller,
                Action     = action,
                Username   = JudgeStatusManager.JudgeUserName,
                UserIP     = this.Request.GetRemoteClientIPv4(),
                UserAgent  = HttpContext.Request.UserAgent,
                TimeStamp  = DateTime.Now,
            };

            LogManager.LogException(context);
        }
Ejemplo n.º 3
0
 public WeatherForecastController(ILogger <WeatherForecastController> logger, ExceptionLogContext exceptionLogContext)
 {
     _logger = logger;
     _exceptionLogContext = exceptionLogContext;
 }