The FilterByRequest()
works as a pre-filter that is called before the action executes, so you won't have the response on the filter delegate.
The option to discard events based on the response is to do a post-filter via a custom action, for example on your startup:
using Audit.WebApi;
Audit.Core.Configuration.AddCustomAction(ActionType.OnEventSaving, scope =>
{
var ev = scope.GetWebApiAuditAction();
if (ev?.ResponseStatusCode == 500 || ev?.ResponseStatusCode == 400)
{
scope.Discard();
}
});