-
Notifications
You must be signed in to change notification settings - Fork 17
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
String arguments are not colorized when using a custom ExpressionTemplate #56
Comments
I'm using the latest console and expression nuget libs (4.0 and 3.2.1 respectively) |
Which terminal are you using? I can't repro with: using Serilog;
using Serilog.Templates;
using Serilog.Templates.Themes;
Log.Logger = new LoggerConfiguration()
.WriteTo.Console(
new ExpressionTemplate("{@m}\n", theme: TemplateTheme.Code)
)
.CreateLogger();
Log.Information("Hello {Name}!", "world"); and <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="serilog.expressions" Version="3.2.1" />
<PackageReference Include="serilog.sinks.console" Version="4.0.0" />
</ItemGroup>
</Project> |
The screenshots are from the JetBrains Rider IDE's integrated terminal. |
Does it repro in other terminals? Thanks! |
Or in Rider, choosing another theme (e.g. |
This issue is still present AFAICT. Using
|
@GerkinDev nice scheme! 😎 The problem with your template is the Would love to see a screenshot of the full theme! :-) |
Indeed removing the format fixed it. But the issue still persist for About the theme, as mentioned in comments, the theme is a very slightly modified version of https://github.com/serilog/serilog-sinks-console/blob/f2351f29330fbd0a33bab62bb63b9c358adadb01/src/Serilog.Sinks.Console/Sinks/SystemConsole/Themes/AnsiConsoleThemes.cs#L21-L40. BTW there should be a normalization of such themes, so that we could convert a theme from Serilog.Sinks.SystemConsole.Themes to a theme valid for this template. |
Yeah, not too sure about scope formatting 🤔 - worth investigating. The unofficial plan I'm working to, though not on any particular timeframe, is for this library to replace all prior filtering/templating/formatting, so we'd no longer need theme support built specifically into Serilog.Sinks.Console. Still a lot of discussion required around that, though. For the time being, it's nice to have Serilog.Expressions outside of the "core" so that it can evolve and improve in ways we probably wouldn't consider if it were already that low in the dependency graph. |
I'm seeing the same issue also when migrating from |
Actually, removing all formatting strings seems to work. Thanks. |
I added my thumbs up to this issue, although I'm not sure if votes are effective here. I will say there are two major issues I ran into that made migration from the default template system to this one challenging:
I think number 1 can be solved with documentation (or if it already exists, I somehow missed it). Number 2 as stated here seems to be broken by using formatters (and as part of the first point, it not being clear that some of them aren't needed, as was the case for I appreciate the workaround from @nblumhardt! |
I noticed that when using a custom ExpressionTemplate, my placeholders in log messages are no longer colorized. Is this a bug? e.g.
Log.Information("foo {bar}", "bar")
won't color the"bar"
anymore.I suspect it's only a problem with string arguments.
My template:
Without ExpressionTemplate:
With ExpressionTemplate:
I'm not sure if this a problem in expressions, or in the console sink.
The text was updated successfully, but these errors were encountered: