当前位置: 首页>>代码示例>>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;未经允许,请勿转载。