aspnet/Logging

Console logger's option `DisableColors` doesn't work from `ConsoleLoggerSettings`

ltcmelo opened this issue · 0 comments

This issue is related to #764 . The option DisableColors has no effect when the logger is created as in the following setup:

            var consoleSettings = new ConsoleLoggerSettings();
            consoleSettings.IncludeScopes = false;
            consoleSettings.DisableColors = true;
            consoleSettings.Switches = new Dictionary<string, LogLevel>
            {
                ["Default"] = LogLevel.Information
            };
            //...
           var logger = new LoggerFactory().AddConsole(consolerSettings).CreateLogger("foo");
           logger.LogInformation("test");

When printing to the console, I continue to get the color control characters.

However, the option DisableColors does work in this simpler scenario:

            var logger = new ConsoleLogger("bar", (b, l) => true, false );
            logger.DisableColors = true;
            logger.LogInformation("test");

Details about my system:
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.302
Commit: 9048955601

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.302/

Host (useful for support):
Version: 2.1.2
Commit: 811c3ce6c0

.NET Core SDKs installed:
2.1.301 [/usr/local/share/dotnet/sdk]
2.1.302 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]