String arguments are not colorized when using a custom ExpressionTemplate
See original GitHub issueI 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:
var template = new ExpressionTemplate(
"[{@l:u3}] {Coalesce(Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1),'Core')} " +
"<{ThreadId}> {@m}\n{@x}", theme: TemplateTheme.Code);
Without ExpressionTemplate:
With ExpressionTemplate:
I’m not sure if this a problem in expressions, or in the console sink.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (5 by maintainers)
Top Results From Across the Web
serilog/serilog-expressions
An embeddable mini-language for filtering, enriching, and formatting Serilog events, ideal for use with JSON or XML configuration.
Read more >Is it possible to change colors in serilog?
Yes, the way to change colors when using the Console sink is through themes. You can try one of the built-in ones, or...
Read more >Customizing Serilog text output
The Coalesce() function accepts a variable number of arguments, and will return the first of them that is not null or undefined.
Read more >Compound Discoverer 3.1 – User Guide (Revision A)
Setting Up a New Study and a New Analysis by Using the Wizard . ... Changing the Hierarchy of the Study Variables ....
Read more >Compound Discoverer 3.0 – User Guide (Revision A)
Creating, Deleting, Importing, or Exporting a Custom Color Palette . . . . . 451 ... using the following user-specified parameter settings:.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
@m:lj
).I appreciate the workaround from @nblumhardt!