public async void LogError(Exception exception, object callParameter1 = null, object callParameter2 = null, [CallerMemberName] string callerFunctionName = null, [CallerFilePath] string callerFileName = null) { AddHeaders(); var userId = Guid.Empty; var claims = httpContextAccessor.HttpContext?.User?.Claims.FirstOrDefault(x => x.Type == ClaimTypes.PrimarySid); if (claims != null) { userId = Guid.Parse(claims.Value); } var apiResult = new ApiResult { Exception = exception, Succeeded = false }; var logItem = new LogItem(new Stopwatch(), userId, Guid.Empty, apiResult, callParameter1, callParameter2, null, callerFunctionName, callerFileName); var responseMessage = await httpClient.PostAsync(configuration["ApiBaseUrl"] + "/api/Log/Add", logItem.AsJsonStringContent()); if (responseMessage.IsSuccessStatusCode) { return; } string text; try { text = responseMessage.Content.ReadAsStringAsync().Result; } catch { text = responseMessage.ReasonPhrase; } throw new Exception(text); }