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);
            }
        }
Пример #2
0
 public override void Log(ExceptionLoggerContext context)
 {
     #if DEBUG
     Debug.WriteLine("Logging");
     #endif
     logger.Log(LogLevel.Trace, context.Exception);
 }
        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);
        }
Пример #4
0
 public override void Log(ExceptionLoggerContext context)
 {
     if (context != null)
     {
         Trace.TraceError(context.ExceptionContext.Exception.ToString());
     }
 }
Пример #5
0
 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);
      }
 }
        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);
        }
        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();
        }
        public Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
        {
            string requestDescription = context.Request.GetDescription();

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

            return Task.FromResult(true);
        }
 public override void Log(ExceptionLoggerContext context) {
     _logger.Error()
         .Exception(context.Exception)
         .SetActionContext(context.ExceptionContext.ActionContext)
         .MarkUnhandled("ExceptionLogger")
         .Message("Unhandled: {0}", context.Exception.Message)
         .Write();
 }
 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);
 }
        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);
        }
Пример #12
0
 public override void Log(ExceptionLoggerContext context)
 {
     if (context?.Exception != null)
     {
         _AiClient.TrackException(context.Exception);
     }
     base.Log(context);
 }
 public override void Log(ExceptionLoggerContext context)
 {
     if (context != null && context.Exception != null)
     {//or reuse instance (recommended!). see note above 
         var ai = new TelemetryClient();
         ai.TrackException(context.Exception);
     }
     base.Log(context);
 }
        public override void Log(ExceptionLoggerContext context)
        {
            // Não loga se for exceção de regra de negócio
            if (context.Exception is BusinessException)
                return;

            // Loga apenas quando for uma Exception (Erro no sistema)
            Trace.TraceError(context.ExceptionContext.Exception.ToString());
        }
 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)
             );
 }
        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);
        }
        public override void Log(ExceptionLoggerContext context)
        {
            //either use tracing for logging
            //Trace.TraceError(context.ExceptionContext.Exception.ToString());
            //or use Semantic Logging Application Block(SLAB)
            //FoodnetworkEventSource.Log.Error("unexpectedError","Error",context.ExceptionContext.Exception.ToString());

            FoodnetworkEventSource.Log.ErrorLog("test");
        }
        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);
            }
        }
Пример #19
0
        public override void Log(ExceptionLoggerContext context)
        {
            using (var log = new LoggerConfiguration().ReadFrom.AppSettings().CreateLogger())
            {
                log.Error(context.Exception, "CustomExceptionLogger: An exception occurred in an API controller; see the log entry below for the request");
            }

            base.Log(context);
        }
Пример #20
0
 public override void Log(ExceptionLoggerContext context)
 {
     if (context != null && context.Exception != null)
     {
         // Note: A single instance of telemetry client is sufficient to track multiple telemetry items.
         var ai = new TelemetryClient();
         ai.TrackException(context.Exception);
     }
     base.Log(context);
 }
Пример #21
0
 public async Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
 {
     // OWIN seems to give lots of these exceptions but we are not interested in them.
     if (context.Exception.Message != "Error while copying content to a stream.")
     {
         Engine.Logger.Error("Unhandled exception: " + context.Exception.GetExceptionDetails());
         var request = await context.Request.Content.ReadAsStringAsync();
         Engine.Logger.Error("Unhandled exception url: " + context.Request.RequestUri);
     }
 }
Пример #22
0
 public  void Log(ExceptionLoggerContext context)
 {
     var logger = GetLoggerInstance();
     if (context.Exception is DbEntityValidationException)
     {
         var exception = (DbEntityValidationException)context.Exception;
         _logger.Error(exception.EntityValidationErrors);
     }
     logger.Error(context.Exception);
 }
        public Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
        {
            Logger.ErrorException("Unhandled exception", context.Exception);

            var env = context.Request.GetOwinEnvironment();
            var events = env.ResolveDependency<IEventService>();
            events.RaiseUnhandledExceptionEvent(context.Exception);

            return Task.FromResult<object>(null);
        }
 public override void Log(ExceptionLoggerContext context)
 {
     var type = typeof(DocumentStoreApplication);
     if (context.ExceptionContext.ControllerContext != null)
     {
         type = context.ExceptionContext.ControllerContext.Controller.GetType();
     }
     var logger = _loggerFactory.Create(type);
     logger.ErrorFormat(context.Exception, "* * * * * * * * * * * *");
 }
        public virtual Task LogAsync(ExceptionLoggerContext context,
                                     CancellationToken cancellationToken)
        {
            if (!ShouldLog(context))
            {
                return Task.FromResult(0);
            }

            return LogAsyncCore(context, cancellationToken);
        }
Пример #26
0
            public override void Log(ExceptionLoggerContext context)
            {
                if (context != null && context.Exception != null)
                {
                    var ai = new TelemetryClient();
                    ai.TrackException(context.Exception);
                }

                base.Log(context);
            }
Пример #27
0
 public override void Log(ExceptionLoggerContext context)
 {
     if (context != null && context.Exception != null)
     {
         ExceptionTelemetry exception = new ExceptionTelemetry(context.Exception);
         exception.HandledAt = ExceptionHandledAt.Unhandled;
             
         client.TrackException(exception);
     }
     base.Log(context);
 }
        public override void Log(ExceptionLoggerContext context)
        {
            string msg = string.Format("{0:yyyyMMdd HH:mm:ss} {1} {2} {3}\r\n",
                DateTime.Now,
                context.Request.Method,
                context.Request.RequestUri,
                context.Exception);

            //寫入Log
            File.AppendAllText(getLogPath(), msg);
        }
Пример #29
0
        public override void Log(ExceptionLoggerContext context) {
            string loggerName = context.Exception.TargetSite?.DeclaringType?.Name ?? "NLogExceptionLogger";

            Logger.Error()
                .Exception(context.Exception)
                .ContextProperty("HttpActionContext", context.ExceptionContext.ActionContext)
                .MarkUnhandled("ExceptionLogger")
                .Message("Unhandled: {0}", context.Exception.Message)
                .LoggerName(loggerName)
                .Write();
        }
Пример #30
0
        public override void Log(ExceptionLoggerContext context)
        {
            _telemetryClient.TrackException(context.Exception,
                                            new Dictionary<string, string>
                                            {
                                                { "Method", context.Request.Method.Method },
                                                { "Url", context.Request.RequestUri.ToString() }
                                            });

            base.Log(context);
        }
Пример #31
0
 /// <summary>When overridden in a derived class, logs the exception asynchronously.</summary>
 /// <param name="context">The exception logger context.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task representing the asynchronous exception logging operation.</returns>
 public virtual Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
 {
     Log(context);
     return(TaskHelpers.Completed());
 }
Пример #32
0
 /// <summary>When overridden in a derived class, logs the exception synchronously.</summary>
 /// <param name="context">The exception logger context.</param>
 public virtual void Log(ExceptionLoggerContext context)
 {
 }