Description
Description
I get a syntax error when embedding a #delimit within an #if block inside a #each loop.
I already log a "StackTrace" property when its present using an #if block to log it first. So then wanted to log the rest of the unused properties excluding it.
I have to add the StackTrace as context with an enricher for a number of 3rd party exceptions that exclude the StackTrace from their ToString(), So SeriLog.Exceptions didn't help on this,
Reproduction
My attempted formatter template included:
{#if Rest(true) <> {}}{#each name, value in Rest(true)}{#if name <> 'StackTrace'}{name}: {value}{#delimit},{#end}{#end}\n{#end}
Expected behavior
I hoped I could use the delimit as per https://github.com/serilog/serilog-expressions#repetition
But with my filter on which properties to log.
Relevant package, tooling and runtime versions
Using current stable Serilog nuget releases.
SeriLog Expressions: 4.0.0
Context
I use an enricher to add the StackTrace from these specific exception types as a property. Then use the below full formatter template. Note it does the delimiter manually and so includes a trailing one. Pus it has wrapping brackets around the properties, which makes it a bit messy to read.
"template": "{UtcDateTime(@t):yyyy-MM-dd HH:mm:ss.fff} +00:00 [{@l}] {@m}\n{#if @x is not null}{@x}{#end}{#if Length(@p['StackTrace']) > 0}{@p.StackTrace}\n{#end}{#if Rest(true) <> {}}{{{#each name, value in Rest(true)}{#if name <> 'StackTrace'}{name}: {value}, {#end}{#end}}}\n{#end}"
If there is a better way to approach filtering the results from Rest(true)
that would be most ideal, but I couldn't see any way and appreciate this is a bit of an odd usage situation.