C# Serilog: How To Log With String Interpolation And Keep Argument Names In Message Templates?
Answer : Add this file to your project. It has ILogger extension methods VerboseInterpolated() , DebugInterpolated() and so on. There are also unit tests here. Usage with format string string name = "John"; // add 'Interpolated' to method name: InformationInterpolated() instead of Information() // add name of the property after the expression. Name is passed to the logger logger.InformationInterpolated($"length of name '{name:name}' is {name.Length:Length}"); But be careful : it's all too easy to use the wrong method. If you accidentally use the Serilog's method, for example logger.Debug($"length = {length:propertyNameForLogger}") , it will log length = propertyNameForLogger , so no argument value will be logged. This is due to propertyNameForLogger is format for your value. Usage with anonymous types string name = "John"; // add 'Interpolated' to method name: InformationInterpolated() instead of...