public void Log(IRequestContext requestContext, object requestDto)
        {
            var httpReq = requestContext.Get<IHttpRequest>();
            var entry = new RequestLogEntry {
                Id = Interlocked.Increment(ref requestId),
                DateTime = DateTime.UtcNow,
                HttpMethod = httpReq.HttpMethod,
                AbsoluteUri = httpReq.AbsoluteUri,
                IpAddress = requestContext.IpAddress,
                PathInfo = httpReq.PathInfo,
                Referer = httpReq.Headers[HttpHeaders.Referer],
                Headers = httpReq.Headers.ToDictionary(),
                UserAuthId = httpReq.GetItemOrCookie(HttpHeaders.XUserAuthId),
                SessionId = httpReq.GetSessionId(),
                Items = httpReq.Items,
            };

            if (HideRequestBodyForRequestDtoTypes != null
                && requestDto != null
                && !HideRequestBodyForRequestDtoTypes.Contains(requestDto.GetType()))
            {
                entry.RequestDto = requestDto;
                entry.FormData = httpReq.FormData.ToDictionary();
            }

            logEntries.Enqueue(entry);

            RequestLogEntry dummy;
            if (logEntries.Count > capacity)
                logEntries.TryDequeue(out dummy);
        }
        public void Log(IRequestContext requestContext, object requestDto, object response, TimeSpan requestDuration)
        {
            var requestType = requestDto != null ? requestDto.GetType() : null;

            if (ExcludeRequestDtoTypes != null
                && requestType != null
                && ExcludeRequestDtoTypes.Contains(requestType))
                return;

            var entry = new RequestLogEntry {
                Id = Interlocked.Increment(ref requestId),
                DateTime = DateTime.UtcNow,
                RequestDuration = requestDuration,
            };

            var httpReq = requestContext != null ? requestContext.Get<IHttpRequest>() : null;
            if (httpReq != null)
            {
                entry.HttpMethod = httpReq.HttpMethod;
                entry.AbsoluteUri = httpReq.AbsoluteUri;
                entry.PathInfo = httpReq.PathInfo;
                entry.IpAddress = requestContext.IpAddress;
                entry.ForwardedFor = httpReq.Headers[HttpHeaders.XForwardedFor];
                entry.Referer = httpReq.Headers[HttpHeaders.Referer];
                entry.Headers = httpReq.Headers.ToDictionary();
                entry.UserAuthId = httpReq.GetItemOrCookie(HttpHeaders.XUserAuthId);
                entry.SessionId = httpReq.GetSessionId();
                entry.Items = httpReq.Items;
                entry.Session = EnableSessionTracking ? httpReq.GetSession() : null;
            }

            if (HideRequestBodyForRequestDtoTypes != null
                && requestType != null
                && !HideRequestBodyForRequestDtoTypes.Contains(requestType))
            {
                entry.RequestDto = requestDto;
                if (httpReq != null) entry.FormData = httpReq.FormData.ToDictionary();
            }
            if (!response.IsErrorResponse()) {
                if (EnableResponseTracking)
                    entry.ResponseDto = response;
            }
            else {
                if (EnableErrorTracking)
                    entry.ErrorResponse = ToSerializableErrorResponse(response);
            }

            logEntries.Enqueue(entry);

            RequestLogEntry dummy;
            if (logEntries.Count > capacity)
                logEntries.TryDequeue(out dummy);
        }