Closed rajeshgithub001 closed 8 months ago
Maybe using DelegatingHandler can solve your problem? For example:
public class FakeHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
//do stuff and optionally call the base handler..
var response = await base.SendAsync(request, cancellationToken);
if (!response.IsSuccessStatusCode)
{
// TODO: Log stuff ...
}
return response;
}
}
I am serilog to log error from ocelot in case of downstream giving any error. Using serilog i am sending the exception details to Application Insight.
Serilog configuration:
Now i want to log request json body in case of error only , How will i do it ?
Middleware didn't work as it didn't catch any ocelot exception, so its out of question.