Hi all,
because a lot of traces are being recorded in the audit log I was wondering if it was possible to set some kind of level to save only the traces that generate an exception.
If this is not possible "out of the box", is it possible to extend the audit-log framework to achieve this?
Thank you in advance.
5 Answer(s)
-
0
Hi,
It is not possible out of box but you can override SaveAsync method of this class <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/master/src/Abp.Zero.Common/Auditing/AuditingStore.cs">https://github.com/aspnetboilerplate/mo ... ngStore.cs</a> and don't save audit log if auditInfo.Exception is null.
Thanks.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
<cite>pumbinha: </cite> Hi all,
because a lot of traces are being recorded in the audit log I was wondering if it was possible to set some kind of level to save only the traces that generate an exception.
If this is not possible "out of the box", is it possible to extend the audit-log framework to achieve this?
Thank you in advance.
This means, that I can use my own AuditingStoreProvider or should I create a new class that inherits from AuditingStore and there I write my own business logic?
I can't find any place in code where the AuditingStoreProvider is set.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Well, I finally found a solution, I leave it here just in case it's useful for someone:
I've created my own AuditingStore class:
public class AuditingStoreExtended : AuditingStore { public AuditingStoreExtended(IRepository<AuditLog, long> auditLogRepository) : base(auditLogRepository) { } public override Task SaveAsync(AuditInfo auditInfo) { Task result = Task.FromResult(new AuditLog()); ; if (auditInfo.Exception != null) { result = base.SaveAsync(auditInfo); } return result; } }After this I injected this new class in XXXCoreModule.cs:
IocManager.Register<IAuditingStore, AuditingStoreExtended>();And now it works perfectly :)
Is this what you meant?
Thanks!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @pumbinha,
Yes, that's it :). I forgot to share dependency injection registration part, sorry.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Is this still the recommended approach to just log exceptions? I have just deleted 1.7 million rows from our audit logs tables!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)