serilog-sinks-opentelemetry
serilog-sinks-opentelemetry copied to clipboard
Mapping enrichers with Resource attributes
Given a configuration similar to the following, would it possible to flow enriched properties to OTEL Resource attributes. For instances, I'd want to be able to set the host.name
attribute with the value from WithMachineName
.
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.Enrich.FromLogContext()
.Enrich.WithThreadId()
.Enrich.WithEnvironmentName()
.Enrich.WithMachineName()
.WriteTo.Console(outputTemplate: outputTemplate)
.WriteTo.OpenTelemetry(opts =>
{
opts.ResourceAttributes = new Dictionary<string, object>
{
["service.name"] = "BackendApiService"
};
})
.CreateLogger();