To use structured logging, you use a concept called ‘message templates’. The are a simple DSL extending .NET form strings. It looks a little bit like string interpolation, but with more power.
A quick example copied from the Serilog website:
The stored message will be a combination of the message template with the placeholders and the properties captured in JSON format:
The only problem is that similar to string.format and in contrast to string interpolation, the compiler doesn’t give any warnings when the provided message template is incorrect or any of the parameters is missing.
A must have if you are using Serilog today! Download the Visual Studio Extension here: https://github.com/Suchiman/SerilogAnalyzer/releases