Skip to content

AuditTo uses shared DB Connection #607

@erviem99

Description

@erviem99

I am trying to use this sink with AuditTo but under heavy load I get errors

System.AggregateException: Failed to emit a log event. (Connection cannot be changed while async operation is in progress.)

This happens from within my logging call in audit.Save()

`
public void Log(string eventType, IDictionary<string, object> customFields = null, string comments = null)
{
using (var audit = auditScopeFactory.Create(new AuditScopeOptions { CreationPolicy = EventCreationPolicy.Manual }))
{
LogInternal(audit, eventType, customFields, comments);
audit.Save();
}
}

`

I think the issue arises because the underlying database connection is being reused inside Serilog and my Log function is called from a thread other than the main thread.

Can anyone confirm this or possibly suggest a fix?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions