Closed MohMehrnia closed 4 years ago
Yes, we've used RavenDB.StructuredLog with thousands of logs. Performance is good. In best case, we use direct read from Raven's Voron storage engine. In worst case, we do an index-backed query. Either way, performance is very good.
Moreover, any background work we do, such as writing Raven, is done in the background. Additionally, if logging in done in quick succession, RavenDB.StructuredLog batches the logs together, writing them to Raven in a single batch.
Does this answer your question?
I mixed Audit.NET and RavenDB.StructuredLog for change capturing, I am worried about the decline in performance for many changes I used below syntaxes for logging:
public override void OnScopeSaving(AuditScope auditScope)
{
try
{
_logger.LogInformation("Audit event recorded: {event}", new
{
IPAddress = _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),
Event = auditScope.Event
});
}
catch (Exception)
{
Database.CurrentTransaction.Rollback();
throw;
}
Database.CurrentTransaction.Commit();
}
}
_logger.LogInformation will never throw. That merely puts logging work on the background thread, to be moved in the database at a later time in bulk. So, you don't need try/catch here.
As for performance, again, there's very little overhead; going across the network to the database is the only resource-heavy thing going on. (And even for that, we do batch work; logging many times in quick succession will result in only 1 trip over the network.) If you feel there still are perf issues, try running a performance profiler and see what comes. I'm quite confident RavenDB.StructuredLog will not be the performance culprit.
I'm sure you're right, I just wanted to make sure, thanks
You have checked the group logging performance for a thousand logs?