Search code examples
c#sonarqube

SonarQube: Log to Console


Is this rule applied to console applications? If yes, how can we log to the conosle then? Or why shouldn't you do it? http://dist.sonarsource.com/plugins/csharp/rulesdoc/0.10.0-RC/S2228.html


Solution

  • You can disable this rule on Console Applications. Nevertheless, even for console applications, it can be a good idea to limit the number of Console.WriteLine() calls for instance to make it easier to later on change your application. For example, you don't want to see Console.* calls spread to the whole codebase, but see it perhaps contained in a single class. If that is the case, feel free to mark those issues as Won't Fix in SonarQube, to indicate that you have reviewed them and that they are expected and accepted.