internal static void LogMessage(IHttpRequest httpRequest, IHttpResponse httpResponse) { try { ServiceMetadata serviceMetadata = EndpointHost.Config.MetadataMap[httpRequest.ServicePath]; Dictionary <string, string> requestData = new Dictionary <string, string>(); if (httpRequest.RequestObject != null && httpRequest.ContentLength > 0 && httpRequest.ContentLength <= MessageLogConfig.RequestLogMaxSize && serviceMetadata.CanLogRequest(httpRequest.OperationName)) { requestData.Add("request", JsonSerializer.SerializeToString(httpRequest.RequestObject)); } Dictionary <string, string> responseData = new Dictionary <string, string>(); if (httpResponse.ResponseObject != null && httpResponse.ExecutionResult != null && httpResponse.ExecutionResult.ResponseSize > 0 && httpResponse.ExecutionResult.ResponseSize <= MessageLogConfig.ResponseLogMaxSize && serviceMetadata.CanLogResponse(httpRequest.OperationName)) { responseData.Add("response", JsonSerializer.SerializeToString(httpResponse.ResponseObject)); } } catch (Exception ex) { Log.Warn("Failed to log request/response messages!", ex, new Dictionary <string, string>() { { "ErrorCode", "FXD300032" } }); } }