protected override void OnException(IInvocation invocation, System.Exception e)
        {
            LogDetailWithException logDetailWithException = GetLogDetail(invocation);

            logDetailWithException.ExceptionMessage = e.Message;
            _loggerServiceBase.Error(logDetailWithException);
        }
        private LogDetailWithException GetLogDetail(IInvocation invocation)
        {
            var logPrameters = new List <LogParameter>();

            for (int i = 0; i < invocation.Arguments.Length; i++)
            {
                logPrameters.Add(new LogParameter()
                {
                    Name  = invocation.GetConcreteMethod().GetParameters()[i].Name,
                    Value = "*", // the content of 'value' is confidential because it may contain important information
                    Type  = invocation.Arguments[i].GetType().Name
                });
            }

            var claimNameIdendifier = httpContextAccessor.HttpContext.User.NameIdentifier();

            var logDetailWithException = new LogDetailWithException()
            {
                MethodName    = $"{invocation.Method.ReflectedType.Name}.{invocation.Method.Name}",
                ClaimId       = claimNameIdendifier,
                LogParameters = logPrameters
            };

            return(logDetailWithException);
        }
        protected override void OnException(IInvocation invocation, System.Exception e)
        {
            // GetLogDetail(invocation) => metodu yollayıp bilgiyi alıyorum
            LogDetailWithException logDetailWithException = GetLogDetail(invocation);

            logDetailWithException.ExceptionMessage = e.Message;
            _loggerServiceBase.Error(logDetailWithException);
        }
示例#4
0
        //S4v44 ==> Try catch işlemlerini gidip arayüz katmanında yapma dıyor
        //backend tarafında oldugu için core tarafında yapıyoruz
        protected override void OnException(IInvocation invocation, System.Exception e)
        {
            //Exception olduğu zaman bunu loglamak hata falan olunca bunu kaydedicez o yuzden burayı yazdık
            LogDetailWithException logDetailWithException = GetLogDetail(invocation);

            logDetailWithException.ExceptionMessage = e.Message;
            _loggerServiceBase.Error(logDetailWithException);
        }
        private LogDetailWithException GetLogDetail(IInvocation invocation)
        {
            var logParameters = invocation.Arguments.Select((t, i) => new LogParameter {
                Name = invocation.GetConcreteMethod().GetParameters()[i].Name, Value = t, Type = t.GetType().Name
            }).ToList();
            var logDetailWithException = new LogDetailWithException
            {
                MethodName = invocation.Method.Name,
                Parameters = logParameters,
                User       = (_httpContextAccessor.HttpContext == null || _httpContextAccessor.HttpContext.User.Identity.Name == null) ? "?" : _httpContextAccessor.HttpContext.User.Identity.Name
            };

            return(logDetailWithException);
        }
示例#6
0
        protected override void OnException(IInvocation invocation, System.Exception e)
        {
            LogDetailWithException logDetailWithException = GetLogDetail(invocation);

            if (e is AggregateException)
            {
                logDetailWithException.ExceptionMessage =
                    string.Join(Environment.NewLine, (e as AggregateException).InnerExceptions.Select(x => x.Message));
            }
            else
            {
                logDetailWithException.ExceptionMessage = e.Message;
            }
            _loggerServiceBase.Error(JsonConvert.SerializeObject(logDetailWithException));
        }
示例#7
0
        protected override void OnException(IInvocation invocation, System.Exception e)
        {
            LogDetailWithException logDetailWithException = GetLogDetail(invocation);

            // g: Eger birden fazla exception varsa yani AggregateException ise icindeki exceptionlari cikar.
            if (e is AggregateException)
            {
                logDetailWithException.ExceptionMessage =
                    string.Join(Environment.NewLine, (e as AggregateException).InnerExceptions.Select(x => x.Message));
            }
            else
            {
                logDetailWithException.ExceptionMessage = e.Message;
            }
            _loggerServiceBase.Error(logDetailWithException);
        }
示例#8
0
        // protected override void OnAfter(IInvocation invocation)
        //  {
        //     you can use like others
        //  }

        private string GetLogDetailWithException(IInvocation invocation, Exception e)
        {
            var logParameters = GetLogParameters(invocation);
            var logDetail     = new LogDetailWithException
            {
                FullName         = invocation.Method.ToString(),
                MethodName       = invocation.Method.Name,
                Parameters       = logParameters,
                User             = _httpContextAccessor.HttpContext?.User.Identity?.Name ?? "?",
                ExceptionMessage = e.Message
            };

            return(JsonConvert.SerializeObject(logDetail, Formatting.None,
                                               new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                DateFormatHandling = DateFormatHandling.IsoDateFormat
            }));
        }
        private LogDetailWithException GetLogDetail(IInvocation invocation)
        {
            var logParameters = new List <LogParameter>();

            for (int i = 0; i < invocation.Arguments.Length; i++)
            {
                logParameters.Add(new LogParameter {
                    Name  = invocation.GetConcreteMethod().GetParameters()[i].Name,
                    Value = invocation.Arguments[i],
                    Type  = invocation.Arguments[i].GetType().Name
                });
            }
            var logDetailWithException = new LogDetailWithException
            {
                MethodName    = invocation.Method.Name,
                LogParameters = logParameters
            };

            return(logDetailWithException);
        }
示例#10
0
        private LogDetailWithException GetLogDetail(IInvocation invocation)
        {
            var logParameters = new List <LogParameter>();

            for (var i = 0; i < invocation.Arguments.Length; i++)
            {
                logParameters.Add(new LogParameter
                {
                    Name  = invocation.GetConcreteMethod().GetParameters()[i].Name,
                    Value = invocation.Arguments[i],
                    Type  = invocation.Arguments[i].GetType().Name
                });
            }
            var logDetailWithException = new LogDetailWithException
            {
                MethodName = invocation.Method.Name,
                Parameters = logParameters,
                User       = (_httpContextAccessor.HttpContext == null || _httpContextAccessor.HttpContext.User.Identity.Name == null) ? "?" : _httpContextAccessor.HttpContext.User.Identity.Name
            };

            return(logDetailWithException);
        }
        private LogDetailWithException GetLogDetail(IInvocation invocation)
        {
            var logParameters = new List <LogParameter>();

            for (int i = 0; i < invocation.Arguments.Length; i++)
            {
                logParameters.Add(new LogParameter()
                {
                    Name  = invocation.GetConcreteMethod().GetParameters()[i].Name,
                    Value = invocation.Arguments[i],
                    Type  = invocation.Arguments[i].GetType().Name,
                });
            }

            var logDetailWithException = new LogDetailWithException
            {
                Email         = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Email)?.Value,
                Target        = invocation.InvocationTarget?.ToString(),
                MethodName    = invocation.Method.Name,
                LogParameters = logParameters,
            };

            return(logDetailWithException);
        }
        private LogDetailWithException GetLogDetail(IInvocation invocation)
        {
            var userName      = _httpContextAccessor.HttpContext.User.ClaimUserName();
            var remoteIp      = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
            var logParameters = new List <LogParameter>();

            for (int i = 0; i < invocation.Arguments.Length; i++)
            {
                logParameters.Add(new LogParameter {
                    Name  = invocation.GetConcreteMethod().GetParameters()[i].Name,
                    Value = invocation.Arguments[i],
                    Type  = invocation.Arguments[i].GetType().Name
                });
            }
            var logDetailWidthException = new LogDetailWithException
            {
                MethodName     = invocation.Method.Name,
                LogParameters  = logParameters,
                RequestingName = userName,
                Ip             = remoteIp
            };

            return(logDetailWidthException);
        }
示例#13
0
        private LogDetailWithException GetLogDetail(IInvocation invocation)
        {
            var logParameters = new List <LogParameter>();

            for (int i = 0; i < invocation.Arguments.Length; i++)
            {
                logParameters.Add(new LogParameter
                {
                    Name  = invocation.GetConcreteMethod().GetParameters()[i].Name,
                    Value = invocation.Arguments[i],
                    Type  = invocation.Arguments[i].GetType().Name
                });
            }

            var logDetailWithException = new LogDetailWithException
            {
                FullName      = invocation.Method.DeclaringType == null ? null : invocation.Method.DeclaringType.Name,
                MethodName    = invocation.Method.Name,
                LogParameters = logParameters,
                DateTime      = DateTime.Now.ToString("G")
            };

            return(logDetailWithException);
        }
 protected override void OnException(IInvocation invocation, System.Exception e)
 {
     LogDetailWithException logDetailWithException = GetLogDetail(invocation);
 }