Aller au contenu

Duplicate log message (ARCH1009)

Ce contenu n’est pas encore disponible dans votre langue.

Key dotnet.logging.duplicate-log-message · Severity info · Category logging · Principle Dry

Repeating the exact same log message in the same class makes it impossible to tell which path an event came from in the logs. Keep messages unique.

public void Create() => _logger.LogInformation("Operation completed");
public void Update() => _logger.LogInformation("Operation completed");
public void Create() => _logger.LogInformation("Create completed");
public void Update() => _logger.LogInformation("Update completed");

Make each log message specific to its operation, or add distinguishing context parameters so the messages are unique.