← back to index

S6669 — Logger field or property name should comply with a naming convention

Language: C#  |  Type: CODE_SMELL  |  Severity: Minor

Tags: logging

Why is this an issue?

Sharing some naming conventions is a key point to make it possible for a team to efficiently collaborate. This rule checks that the logger field or property name matches a provided regular expression.

The rule supports the most popular logging frameworks:

How to fix it

Update the name of the field or property to follow the configured naming convention. By default, the following names are considered compliant:

Noncompliant code example

private readonly ILogger myLogger; // Noncompliant

public ILogger MyLogger { get; set; } // Noncompliant

Compliant solution

private readonly ILogger logger; // Compliant

public ILogger Logger { get; set; } // Compliant

Resources

Documentation