Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TraceId and SpanId are missing from the logs #195

Closed
KrishnaKole opened this issue Apr 17, 2024 · 4 comments
Closed

TraceId and SpanId are missing from the logs #195

KrishnaKole opened this issue Apr 17, 2024 · 4 comments
Assignees
Labels

Comments

@KrishnaKole
Copy link

KrishnaKole commented Apr 17, 2024

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?

@EEParker
Copy link
Collaborator

I added a reproduction case #196. I looks like this is related to some internal changes to dotnet 6.0 and up, see dotnet/runtime#34305

I found a related MR to serilog here: https://github.com/serilog/serilog/pull/1955/files#diff-b111b459384a29d3e58a068b0b47c05777172c9974217fb615a6976c70841de7

@EEParker
Copy link
Collaborator

image
This will be fixed with 4.0.4

EEParker added a commit that referenced this issue Apr 19, 2024
* Attempt reproduction of #195

* Fix for #195, add TraceId and SpanId to log
@EEParker
Copy link
Collaborator

EEParker commented Apr 19, 2024

@KrishnaKole once 4.0.4 is available on nuget, can you confirm this is fixed?

@EEParker EEParker self-assigned this Apr 19, 2024
@EEParker EEParker added the bug label Apr 19, 2024
@KrishnaKole
Copy link
Author

Yes, it is fixed with 4.0.4. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants