Named placeholders in message templates should be unique. The meaning of the named placeholders is to store the value of the provided argument under that name, enabling easier log querying. Since the named placeholder is used multiple times, it cannot store the different values uniquely with each name hence not serving its original purpose. There can be different behaviours when using the same named placeholder multiple times:
_index The rule covers the following logging frameworks:
Assign unique names to each template placeholder.
public void Checkout(ILogger logger, User user, Order order)
{
logger.LogDebug("User {Id} purchased order {Id}", user.Id, order.Id);
}
public void Checkout(ILogger logger, User user, Order order)
{
logger.LogDebug("User {UserId} purchased order {OrderId}", user.Id, order.Id);
}
Serilog005: Unique
Property Name Verifier