コード例 #1
0
        private void LogRequest(HttpRequest requestinfo, string TraceIdentifier = null)
        {
            //var body = request.Body;
            //request.EnableRewind();
            //var buffer = new byte[Convert.ToInt32(request.ContentLength)];
            //await request.Body.ReadAsync(buffer, 0, buffer.Length);
            //var bodyAsText = Encoding.UTF8.GetString(buffer);
            //request.Body = body;

            var request = LogHttpRequest.ToLogHttpRequest(requestinfo, TraceIdentifier);

            _logger.LogInformation(message: "{@request} registered", args: request);
        }
コード例 #2
0
        public static LogHttpRequest ToLogHttpRequest(HttpRequest request, string TraceIdentifier = null)
        {
            var logg = new LogHttpRequest
            {
                Scheme      = request.Scheme,
                Host        = request.Host,
                Path        = request.Path,
                QueryString = request.QueryString,

                Headers       = request.Headers.ToList(),
                ContentLength = request.ContentLength,
                ContentType   = request.ContentType,

                TraceIdentifier = TraceIdentifier
            };

            return(logg);
        }