Comments (2)
You can accomplish what you want by setting up a custom action that discards the audit scope, so the audit event won't be saved:
Audit.Core.Configuration.AddCustomAction(ActionType.OnEventSaving, scope =>
{
if (scope.GetWebApiAuditAction().ResponseStatusCode == 404)
{
scope.Discard();
}
});
Anyway, you can work on a PR if you want, very welcome!
Take into account that:
- There is no
IncludeResponseBodyIf
. Not sure if you are referring to the middleware'sIncludeResponseBody(Func<HttpContext, bool> includePredicate)
but that cannot filter on the response, since the predicate is executed before the action method is called. - The
AuditScope
/AuditEvent
is created before the server processes the request, so if we provide a method to filter audits depending on the response, we should maybe call itDiscardIf
, or something like that.
from audit.net.
Ahh thanks for the explanation
I was mixing up IncludeResponseBodyFor
and LogActionIf
.
Since I messed up that I ust want to be clear:
I am talking about adding another Property to the AuditApiAttribute
if possible.
Presuambly it should be DiscardIfNot or ExcudeAuditIfNot (the negation in the naming here would be because I think the most common need is to only audit on success, and listing ALL the status codes you want to discard seems tedious).
I will give it a spin and see what comes out of it, feel free to reject the idea before it gets anywhere :D
from audit.net.
Related Issues (20)
- Support CancellationToken on all async methods HOT 3
- I get a missing method Exception when saving HOT 11
- Response content not capturing correctly when Exception Handlers is used HOT 1
- [AuditApi] - override middleware settings with controller attributes HOT 3
- Error on inserting Audit Data HOT 2
- EF Core value updates not audited HOT 3
- EF Core value updates are not audited HOT 13
- Custom field empty in Entries Array HOT 3
- Bump Microsoft.Bcl.AsyncInterfaces HOT 1
- Limited configuration of MongoDB provider HOT 1
- Related object causes multiple audit entries HOT 3
- How to use WebApi / Serilog with .Net 4.7.2 HOT 9
- Extra Double Quote in PostgreSqlDataProvider Generated SQL HOT 2
- Sometimes when auditing to CosmosDB a CosmosException occurs HOT 5
- Since the new version of mongo-csharp-driver The Jobject for AuditTarget cannot be serialized/deserialized HOT 2
- AuditCommandInterceptor IncludeReaderResults = true results in "DataReader Open" error HOT 9
- Missing Method Exception: Microsoft.EntityFrameworkCore.Metadata.IEntityType.GetProperties() HOT 3
- Best way to "Include" related entity properties HOT 3
- Audit.EntityFramework.Core add support for EF8 Complex Types HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audit.net.