private void SendLog <T>(ISearchResponse <T> result, string identifier, TimeSpan clientRequestTime) where T : class { var body = string.Empty; if (result.ApiCall.RequestBodyInBytes != null) { body = System.Text.Encoding.Default.GetString(result.ApiCall.RequestBodyInBytes); } var logEntry = new ElasticSearchLogEntry { Identifier = identifier, ReturnCode = result.ApiCall?.HttpStatusCode, Successful = result.ApiCall?.Success, SearchTime = (int)result.Took, RequestTime = Math.Round(clientRequestTime.TotalMilliseconds, 2), MaxScore = result.MaxScore, HitCount = result.Hits?.Count(), Url = result.ApiCall?.Uri?.AbsoluteUri, Body = body }; var dependencyLogEntry = new DependencyLogEntry { Identifier = identifier, ResponseCode = result.ApiCall?.HttpStatusCode, ResponseTime = Math.Round(clientRequestTime.TotalMilliseconds, 2), Url = result.ApiCall?.Uri?.AbsoluteUri }; _logger.LogDebug("Elastic Search Requested", logEntry); _logger.LogDebug("Dependency Elasticsearch", dependencyLogEntry); }
private void SendLog(IApiCallDetails apiCallDetails, long?took, double networkTime, string identifier) { string body = string.Empty; if (apiCallDetails?.RequestBodyInBytes != null) { body = System.Text.Encoding.Default.GetString(apiCallDetails.RequestBodyInBytes); } var logEntry = new ElasticSearchLogEntry { ReturnCode = apiCallDetails?.HttpStatusCode, SearchTime = took, NetworkTime = networkTime, Url = apiCallDetails?.Uri?.AbsoluteUri, Body = body }; _logger.Debug($"ElasticsearchQuery: {identifier}", logEntry); }