Aspnetcore.docs: How do I escape {fooBar} in log message template, so it is not treated as a placeholder?

Created on 31 Oct 2020  ·  4Comments  ·  Source: dotnet/AspNetCore.Docs

Logger.LogDebug("{fooBar} status is {status}", status);

Is there any way to mark {fooBar} just as a literal instead of a placeholder?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Source - Docs.ms doc-enhancement

Most helpful comment

Ok, tried it, and it works, also to make it like {10} it should be {{{id}}}.
And it becomes braces madness, if you combine template with string interpolation: $"{nameof(id)} = {{{{{{id}}}}}}" :-D

All 4 comments

Hello @voroninp ... Did you try a double-brace?

Logger.LogDebug("{{fooBar}} status is {status}", status);

If that works, leave this open. It's probably worth mentioning.

Ok, tried it, and it works, also to make it like {10} it should be {{{id}}}.
And it becomes braces madness, if you combine template with string interpolation: $"{nameof(id)} = {{{{{{id}}}}}}" :-D

I realize that it's 👹 Halloween 👹 and all ..... _but don't ScArE me like that!!!!_ 🎃👻 I felt the chill of cold death ⚰️ come over me when you sprang that 🔥 Braces from Hell 🔥 example on me! lol

Rick will be on later or Monday to take a look. He'll determine if a mention of it would be good. Leave this issue open for him.

Was this page helpful?
0 / 5 - 0 ratings