I'm using aspnet boilerplate and I've successfully trimmed down exactly which methods are/are not logged, by using the [DisableAuditing]
and [Audited]
attributes. So that part is working great, and I'm satisfied with my logging levels. However, I don't understand how to effectively use the CustomData field. I'd like to use this field to save certain additional data that is not captured by default, but I don't understand how to set it, or where. Thanks in advance for any advice.
You can subclass AuditingStore
and set CustomData
to your data:
public class MyAuditingStore : AuditingStore
{
public MyAuditingStore(IRepository<AuditLog, long> auditLogRepository)
: base(auditLogRepository)
{
}
public override Task SaveAsync(AuditInfo auditInfo)
{
auditInfo.CustomData = "certain additional data that is not captured by default";
return base.SaveAsync(auditInfo);
}
}
Then replace IAuditingStore
in your module:
// using Abp.Configuration.Startup;
public override void PreInitialize()
{
Configuration.ReplaceService<IAuditingStore, MyAuditingStore>(DependencyLifeStyle.Transient);
}