當前位置: 首頁>>代碼示例>>C#>>正文


C# ExceptionHandling.ExceptionLoggerContext類代碼示例

本文整理匯總了C#中System.Web.Http.ExceptionHandling.ExceptionLoggerContext的典型用法代碼示例。如果您正苦於以下問題:C# ExceptionLoggerContext類的具體用法?C# ExceptionLoggerContext怎麽用?C# ExceptionLoggerContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ExceptionLoggerContext類屬於System.Web.Http.ExceptionHandling命名空間,在下文中一共展示了ExceptionLoggerContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Log

        public override void Log(ExceptionLoggerContext context)
        {
            if (context != null && context.Exception != null && context.Request != null)
            {
                string excToString = context.Exception.ToString();

                var entityValidationExc = context.Exception as System.Data.Entity.Validation.DbEntityValidationException;
                if (entityValidationExc != null)
                    excToString += Environment.NewLine
                                + string.Join(Environment.NewLine, entityValidationExc.EntityValidationErrors.SelectMany(p => p.ValidationErrors.Select(q => q.PropertyName + ": " + q.ErrorMessage)));

                var usedController = ((System.Web.Http.ApiController)context.ExceptionContext.ControllerContext.Controller);

                //similar to Global.asax/CustomLogRequest
                //todo: missing user and IP, catch Exceptions and null reference
                Trace.TraceError("CustomExceptionLogger"
                                 + Environment.NewLine
                                 + "HTTP {0} {1}"
                                 + Environment.NewLine
                                 + "Form Keys: {2}"
                                 + Environment.NewLine,
                                 //+ "User: {3}, IP: {4}",
                                 context.Request.Method.Method, context.Request.RequestUri,
                                 string.Join(Environment.NewLine,
                                            usedController.ActionContext.ActionArguments.Select(p => p.Key + ": " + JsonConvert.SerializeObject(p.Value))));
                //username, ip);
            }
        }
開發者ID:Simone000,項目名稱:SPA_Template,代碼行數:28,代碼來源:CustomExceptionLogger.cs

示例2: Log

 public override void Log(ExceptionLoggerContext context)
 {
     if (context != null)
     {
         Trace.TraceError(context.ExceptionContext.Exception.ToString());
     }
 }
開發者ID:olehkrut,項目名稱:WorldOfWords,代碼行數:7,代碼來源:TraceExceptionLogger.cs

示例3: LogAsync

        public Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
        {
            var logger = context.Request.GetAutofacScope().Resolve<ILogger>();
            logger.ErrorFormat("Unhandled exception: {0}", context.Exception);

            return Task.FromResult<object>(null);
        }
開發者ID:JackBao,項目名稱:Thinktecture.IdentityServer.v3,代碼行數:7,代碼來源:IdentityServerExceptionLogger.cs

示例4: Log

 public override void Log(ExceptionLoggerContext context)
 {
     #if DEBUG
     Debug.WriteLine("Logging");
     #endif
     logger.Log(LogLevel.Trace, context.Exception);
 }
開發者ID:crypteron,項目名稱:cloudmedic,代碼行數:7,代碼來源:Logger.cs

示例5: Log

        public override void Log(ExceptionLoggerContext context) {
            var contextData = new ContextData();
            contextData.MarkAsUnhandledError();
            contextData.SetSubmissionMethod("ExceptionLogger");
            contextData.Add("HttpActionContext", context.ExceptionContext.ActionContext);

            context.Exception.ToExceptionless(contextData).Submit();
        }
開發者ID:InlineAsm,項目名稱:Exceptionless.Net,代碼行數:8,代碼來源:ExceptionlessExceptionLogger.cs

示例6: Log

 public override void Log(ExceptionLoggerContext context)
 {
     var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data");
     path = Path.Combine(path, "UserAdminException.txt");
     Directory.CreateDirectory(path);
     var msg = DateTime.Now.ToString() + Environment.NewLine + context.Exception.ToString() + Environment.NewLine + Environment.NewLine;
     File.AppendAllText(path, msg);
 }
開發者ID:Webdiyer,項目名稱:Thinktecture.IdentityManager,代碼行數:8,代碼來源:WebApiConfig.cs

示例7: LogAsync

        public Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
        {
            string requestDescription = context.Request.GetDescription();

            logger.WriteCritical($"Exception while processing {requestDescription}.", context.Exception);

            return Task.FromResult(true);
        }
開發者ID:jochenz,項目名稱:unit-testing-restful-services,代碼行數:8,代碼來源:ExceptionLogger.cs

示例8: Log

        public void Log(Exception ex, HttpRequestMessage request, string catchBlockName)
        {
            var catchBlock = new ExceptionContextCatchBlock(catchBlockName, true, false);
            var exceptionContext = new ExceptionContext(ex, catchBlock, request);
            var exceptionLoggerContext = new ExceptionLoggerContext(exceptionContext);

            Log(exceptionLoggerContext);
        }
開發者ID:gitter-badger,項目名稱:WealthEconomy,代碼行數:8,代碼來源:ElmahExceptionLogger.cs

示例9: Log

 public override void Log(ExceptionLoggerContext context)
 {
     using (var log = Logger.GetLogger(this))
      {
     string errorMessage = $"Unhandled exception processing {context.Request.Method} for {context.Request.RequestUri}: {context.Exception}";
     log.Error(errorMessage);
      }
 }
開發者ID:bouwe77,項目名稱:fmg,代碼行數:8,代碼來源:MyExceptionLogger.cs

示例10: LogAsync

        public async Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
        {
            Logger.ErrorException("Unhandled exception", context.Exception);

            var env = context.Request.GetOwinEnvironment();
            var events = env.ResolveDependency<IEventService>();
            await events.RaiseUnhandledExceptionEventAsync(context.Exception);
        }
開發者ID:284247028,項目名稱:IdentityServer3,代碼行數:8,代碼來源:LogProviderExceptionLogger.cs

示例11: Log

 public override void Log(ExceptionLoggerContext context) {
     _logger.Error()
         .Exception(context.Exception)
         .SetActionContext(context.ExceptionContext.ActionContext)
         .MarkUnhandled("ExceptionLogger")
         .Message("Unhandled: {0}", context.Exception.Message)
         .Write();
 }
開發者ID:rpotalara,項目名稱:Exceptionless,代碼行數:8,代碼來源:FoundatioExceptionLogger.cs

示例12: Log

 public override void Log(ExceptionLoggerContext context)
 {
     if (context?.Exception != null)
     {
         _AiClient.TrackException(context.Exception);
     }
     base.Log(context);
 }
開發者ID:XnainA,項目名稱:app-crm,代碼行數:8,代碼來源:AiExceptionLogger.cs

示例13: ShouldLogAsError

 private bool ShouldLogAsError(ExceptionLoggerContext context)
 {
     return (!(context.Exception is MdmFaultException) &&
             !(context.Exception is NotFoundException) &&
             !(context.Exception is ValidationException) &&
             !(context.Exception is NotImplementedException) &&
             !(context.Exception is VersionConflictException)
             );
 }
開發者ID:RWE-Nexus,項目名稱:EnergyTrading-MDM,代碼行數:9,代碼來源:DefaultExceptionLogger.cs

示例14: Log

        public override void Log(ExceptionLoggerContext context)
        {
            var shouldBeWarning = Extension.IsType(context.Exception, new List<Type> { typeof(ValidationException), typeof(BaseLogicException<>) });

            if (shouldBeWarning)
                Logger.Warn(context.Exception.GetType().Name, context.Exception);
            else
                Logger.Error("An unhandled exception has occured", context.Exception);
        }
開發者ID:tomekjanicki,項目名稱:architecture2,代碼行數:9,代碼來源:ApiExceptionLogger.cs

示例15: Log

        public override void Log(ExceptionLoggerContext context)
        {
            var logger = context.Request.GetDependencyScope().GetService(typeof(ILogger)) as ILogger;

            if (logger != null && context.Exception != null)
            {
                logger.Log(context.Exception.Message);
            }
        }
開發者ID:robinvanderknaap,項目名稱:PizzaApi,代碼行數:9,代碼來源:UnhandledExceptionLogger.cs


注:本文中的System.Web.Http.ExceptionHandling.ExceptionLoggerContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。