We are seeing server-wide issues and it looks like thousands of threads are being blocked by the Serilog.Sinks.Async.BackgroundWorkerSink. We believe the issue is most likely something with the file sink, and are wondering:
- Is it wise to have “shared:true” for the file sink?
- Is it wise to combine the elastic search sink with the async sink?
- Isn’t Serilog supposed to use the Treadpool? Why then do we have ~3000 threads?
var logCfg =
new LoggerConfiguration()
.Enrich.WithProperty("machine", System.Environment.MachineName)
.WriteTo.Map(keyPropertyName: "$filename", defaultKey: "fallback",
configure: (fileName, wt) =>
wt.Async(c =>
c.File(formatter: formatter
, path: logOptions.AuditPath
, shared: true
, fileSizeLimitBytes: fileSizeLimitBytes ?? 41943040
, rollingInterval: RollingInterval.Day
, rollOnFileSizeLimit: true
)
)
)
.WriteTo.Async(c =>
c.Elasticsearch(new Serilog.Sinks.Elasticsearch.ElasticsearchSinkOptions(new Uri(elasticUrl))
{
IndexFormat = "my-audit-" + DateTime.Now.Year,
ModifyConnectionSettings = x => x.MyAuthentication(elasticCreds[0], elasticCreds[1])
}
)
);
Nuget versions:
- Serilog.Sinks.Async 1.5.0.0
- Serilog.sinks.Elasticsearch 8.4.1
- Serilog.Sinks.File 5.0.0
We are seeing server-wide issues and it looks like thousands of threads are being blocked by the Serilog.Sinks.Async.BackgroundWorkerSink. Our configuration is as follows:
var logCfg =
new LoggerConfiguration()
.Enrich.WithProperty("machine", System.Environment.MachineName)
.WriteTo.Map(keyPropertyName: "$filename", defaultKey: "fallback",
configure: (fileName, wt) =>
wt.Async(c =>
c.File(formatter: formatter
, path: logOptions.AuditPath
, shared: true
, fileSizeLimitBytes: fileSizeLimitBytes ?? 41943040
, rollingInterval: RollingInterval.Day
, rollOnFileSizeLimit: true
)
)
)
.WriteTo.Async(c =>
c.Elasticsearch(new Serilog.Sinks.Elasticsearch.ElasticsearchSinkOptions(new Uri(elasticUrl))
{
IndexFormat = "my-audit-" + DateTime.Now.Year,
ModifyConnectionSettings = x => x.MyAuthentication(elasticCreds[0], elasticCreds[1])
}
)
);
We are using a Serilog file sink and an Elasticsearch sink, both using a Serilog async sink. We are wondering:
- Is it wise to have “shared:true” for the file sink?
- Is it wise to combine the Elasticsearch sink with the async sink?
- Isn’t Serilog supposed to use the Threadpool? Why then do we have ~3000 threads?
Nuget versions:
- Serilog.Sinks.Async 1.5.0.0
- Serilog.sinks.Elasticsearch 8.4.1
- Serilog.Sinks.File 5.0.0