How-to
Read the audit log
Where the audit log goes
The SDK writes audit events through the standard .NET logging system. Events appear wherever your ILoggerFactory sends them:
- Console (by default in development)
- Files via Serilog, NLog, etc.
- Cloud log services (Application Insights, CloudWatch, etc.)
What gets logged
| Event | Level |
|---|---|
| Policy reloaded (reason, rule count) | Information |
| Policy rule added or removed | Information |
| Authorization decision (deny details) | Information |
| Last rule removed (warning) | Warning |
| Swarm mode enabled | Information |
| Lock acquired / released / reclaimed | Information |
Routing to Serilog
using Serilog;
Log.Logger = new LoggerConfiguration()
.WriteTo.File("agent-audit.log")
.CreateLogger();
var factory = LoggerFactory.Create(b => b.AddSerilog());
var logger = factory.CreateLogger<Program>();
var client = new Client();
// Pass the logger to the authorization provider
var policies = new CasbinAuthorizationProvider("policy.csv", logger);
client.UseAuthorizationProvider(policies); See also
- Inspect the policy file How-to
- Trace a denied request How-to