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

Structured logging does not work with Microsoft.Extensions.Logging.Abstractions 6.0.0 #291

Open
jb-medivet opened this issue Mar 4, 2022 · 2 comments

Comments

@jb-medivet
Copy link

Description
When writing logs using the ILogger<T> API from M.E.L.A v6.0.0, Serilog does not detect any log parameters. Works as expected after downgrading to v5.0.0

Reproduction

Serilog configured with:

        public static IHostBuilder ConfigureLogger(this IHostBuilder builder)
            => builder.UseSerilog((context, services, loggerConfiguration)
                => loggerConfiguration
                    .ReadFrom.Configuration(context.Configuration)
                    .WriteTo.Console()
                    .WriteTo.ApplicationInsights(services.GetRequiredService<TelemetryConfiguration>(), TelemetryConverter.Traces));

Logs written as:

using Microsoft.Extensions.Logging;
...
private readonly ILogger<MyClass> _logger;
...
_logger.LogInformation("The value is {Value}", value);

Expected behaviour

  1. The console should display the log with the usual colour coding.
  • Note: it does display the log, but without the colour coding.
  1. App Insights should contain the log with custom dimensions 'Value' = "[the-value]" and 'MessageTemplate' = "The value is {Value}"
  • Note: it does contain the log, but the 'Value' custom dimension is not included, and the 'MessageTemplate' contains the resolved string i.e. "The value is [the-value]"

Relevant package, tooling and runtime versions

  • net5.0
  • Serilog.AspNetCore 5.0.0
  • Serilog.Sinks.ApplicationInsights 3.1.0
@jb-medivet jb-medivet added the bug label Mar 4, 2022
@nblumhardt
Copy link
Member

Thanks for taking the time to let us know. Would it be possible to assemble a reproduction, ideally using only the Console sink and CompactJsonFormatter() or JsonFormatter(), that demonstrates the issue? (If not, this may be a Serilog.Sinks.ApplicationInsights problem, and would need to be transferred to/dealt with in that repository).

@christianerbsmehl
Copy link

christianerbsmehl commented Jul 26, 2022

Same here. I just upgraded a .NET Core 3.1 project to .NET 6 using Serilog.AspNetCore 6.0.1 and Serilog.Sinks.Splunk 3.7.0.
Same observations: Console output is not colored anymore and message properties in Splunk are missing.
I'll try to provide you a sample project.

Edit: While creating the sample project I realized that this problem only occurs if I add the Steeltoe.Extensions.Logging.DynamicSerilogBase NuGet package. I will file an issue in their repository.

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

No branches or pull requests

3 participants