Exemple #1
0
        public IActionResult SignOut()
        {
            var correlationId = JwtTokenProvider.GetCorrelationIdForLogging(HttpContext.User);

            _auditLogger.Info("Gebruiker uitgelogd", correlationId);

            return(Ok());
        }
Exemple #2
0
        public async Task Invoke(HttpContext context)
        {
            try
            {
                await _next(context);
            }
            catch (Exception exception)
            {
                var calledUrl     = context.Request.GetDisplayUrl();
                var correlationId = JwtTokenProvider.GetCorrelationIdForLogging(context.User);
                Log4NetLogManager.ErrorLogger.Error($"Onverwachte fout bij het opvragen van URL '{calledUrl}'", correlationId, exception);

                throw;
            }
        }
Exemple #3
0
        private void ConfigureServiceClient(IServiceProvider serviceProvider, HttpClient httpClient)
        {
            var httpContextAccessor = serviceProvider.GetService <IHttpContextAccessor>();
            var correlationId       = JwtTokenProvider.GetCorrelationIdForLogging(httpContextAccessor.HttpContext.User);

            httpClient.DefaultRequestHeaders.Add("X-NLX-Logrecord-ID", correlationId);
            httpClient.DefaultRequestHeaders.Accept.Clear();
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var frontEndHeaders = httpContextAccessor.HttpContext.Request.Headers;

            if (frontEndHeaders.ContainsKey("X-NLX-Request-Process-Id"))
            {
                var processId = frontEndHeaders["X-NLX-Request-Process-Id"].ToString();
                httpClient.DefaultRequestHeaders.Add("X-NLX-Request-Process-Id", processId);
            }
        }
        public async Task Invoke(HttpContext context)
        {
            var request       = FormatRequest(context.Request);
            var correlationId = JwtTokenProvider.GetCorrelationIdForLogging(context.User);

            await _next(context);

            var response = FormatResponse(context.Response);

            if (context.Response.StatusCode.Equals(200))
            {
                Log4NetLogManager.AuditLogger.Info($"{Environment.NewLine}Request: {request}{Environment.NewLine}Response:{response}", correlationId);
            }
            else
            {
                Log4NetLogManager.AuditLogger.Warn($"{Environment.NewLine}Request: {request}{Environment.NewLine}Response:{response}", correlationId);
            }
        }