Skip to content

TraceId and SpanId are missing from the logs #195

@KrishnaKole

Description

@KrishnaKole

I am using v4.0.3 of this sink with below setup:

        Log.Logger = new LoggerConfiguration()
            .Destructure.UsingAttributes()
            .Enrich.FromLogContext()
            .Enrich.WithExceptionDetails()
            .Enrich.WithCorrelationId(StaticConfig.CorrelationIdHeader, addValueIfHeaderAbsence: true)
            .WriteTo.Conditional(
                _ => !builder.Environment.IsDevelopment(),
                wt => wt.EventCollector(
                    splunkConfig.BaseUri,
                    splunkConfig.Token,
                    "services/collector/event",
                    splunkConfig.AppSource ?? Assembly.GetEntryAssembly()?.GetName().Name ?? string.Empty,
                    sourceType: "",
                    splunkConfig.AppHost ?? Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME", EnvironmentVariableTarget.Process) ?? Environment.MachineName,
                    splunkConfig.Index
                )
            )
            .WriteTo.Conditional(
                _ => builder.Environment.IsDevelopment(),
                wt => wt.Console(
                    outputTemplate:
                    "[{Timestamp:yyyy.MM.dd HH:mm:ss} {TraceId} {SpanId} {CorrelationId} {Level:u3}] {Message:lj} {Properties:j} {NewLine}{Exception}"
                )
            )
            .ReadFrom.Configuration(builder.Configuration)
            .CreateLogger();
       builder.Host.UseSerilog();

I get the TraceId and SpanId in console logs, but they are missing from the logs
image

Am I doing something wrong?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions