Providing property values
Last updated
Last updated
There are several supported ways to pass property values for placeholders in when using .
Property names are inferred from placeholders in message template.
If arguments count exceeds template placeholders count, excess arguments are named with numbers denoting their positions:
If provided arguments count is not sufficient to account for all template placeholders, the names for existing arguments are still inferred.
When using this syntax, user is responsible for making sure that object property names match the names of placeholders in message template.
Despite being somewhat deprecated nowadays, this syntax enables gradual migration from libraries that do not support structured logging.
It also supports multiple occurrences of the same placeholder within a single template:
When using this syntax, user is responsible for making sure that new C# 10 features are enabled and Vostok.Logging.Abstractions library targets .NET 6.
If you want to disable automatic properties extraction from an interpolated string directly cast it to the string:
Or disable it entirely for your application:
For the same reasons, do not pass properties with invalid names (such as function calls). Instead of:
you should use:
It also supports :
However, in this case, you may have performance issues (due to the internal templates cache) or corrupted messages (due to the rendering stage). See documentation for details.