From bc6ed3f6d9dbe0edef80d2720e4020ea0bc80a15 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 16 Feb 2023 12:42:23 -0600 Subject: [PATCH] Refactor Logging.Console configure options - Use nameof instead hard-coded strings - Move the configuration binding code to the options class. This allows the configure method to be virtual and only need a single ConsoleFormatterOptions class. - Minor cleanup --- .../src/ConsoleFormatterConfigureOptions.cs | 22 +-- .../src/ConsoleFormatterOptions.cs | 21 ++- .../src/ConsoleLoggerConfigureOptions.cs | 145 +----------------- .../src/ConsoleLoggerExtensions.cs | 5 +- .../src/ConsoleLoggerOptions.cs | 143 +++++++++++++++++ .../JsonConsoleFormatterConfigureOptions.cs | 57 ------- .../src/JsonConsoleFormatterOptions.cs | 28 ++++ .../SimpleConsoleFormatterConfigureOptions.cs | 44 ------ .../src/SimpleConsoleFormatterOptions.cs | 17 ++ .../ConsoleLoggerTest.cs | 2 - 10 files changed, 213 insertions(+), 271 deletions(-) delete mode 100644 src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatterConfigureOptions.cs delete mode 100644 src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatterConfigureOptions.cs diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterConfigureOptions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterConfigureOptions.cs index 106c3c8263e64e..41909de809f41b 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterConfigureOptions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterConfigureOptions.cs @@ -16,34 +16,16 @@ namespace Microsoft.Extensions.Logging /// Doesn't use ConfigurationBinder in order to allow ConfigurationBinder, and all its dependencies, /// to be trimmed. This improves app size and startup. /// - [UnsupportedOSPlatform("browser")] internal sealed class ConsoleFormatterConfigureOptions : IConfigureOptions { private readonly IConfiguration _configuration; + [UnsupportedOSPlatform("browser")] public ConsoleFormatterConfigureOptions(ILoggerProviderConfiguration providerConfiguration) { _configuration = providerConfiguration.GetFormatterOptionsSection(); } - public void Configure(ConsoleFormatterOptions options) => Bind(_configuration, options); - - public static void Bind(IConfiguration configuration, ConsoleFormatterOptions options) - { - if (ConsoleLoggerConfigureOptions.ParseBool(configuration, "IncludeScopes", out bool includeScopes)) - { - options.IncludeScopes = includeScopes; - } - - if (configuration["TimestampFormat"] is string timestampFormat) - { - options.TimestampFormat = timestampFormat; - } - - if (ConsoleLoggerConfigureOptions.ParseBool(configuration, "UseUtcTimestamp", out bool useUtcTimestamp)) - { - options.UseUtcTimestamp = useUtcTimestamp; - } - } + public void Configure(ConsoleFormatterOptions options) => options.Configure(_configuration); } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterOptions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterOptions.cs index 7ab51ad8c1e8ce..408afda399db92 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterOptions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleFormatterOptions.cs @@ -1,9 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Diagnostics.CodeAnalysis; -using System.Text; +using Microsoft.Extensions.Configuration; namespace Microsoft.Extensions.Logging.Console { @@ -32,5 +31,23 @@ public ConsoleFormatterOptions() { } /// Gets or sets indication whether or not UTC timezone should be used to format timestamps in logging messages. Defaults to false. /// public bool UseUtcTimestamp { get; set; } + + internal virtual void Configure(IConfiguration configuration) + { + if (ConsoleLoggerOptions.ParseBool(configuration, nameof(IncludeScopes), out bool includeScopes)) + { + IncludeScopes = includeScopes; + } + + if (configuration[nameof(TimestampFormat)] is string timestampFormat) + { + TimestampFormat = timestampFormat; + } + + if (ConsoleLoggerOptions.ParseBool(configuration, nameof(UseUtcTimestamp), out bool useUtcTimestamp)) + { + UseUtcTimestamp = useUtcTimestamp; + } + } } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerConfigureOptions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerConfigureOptions.cs index c0bd42be6f97be..dc4b98b0a02ff2 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerConfigureOptions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerConfigureOptions.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; using System.Runtime.Versioning; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging.Configuration; @@ -18,155 +16,16 @@ namespace Microsoft.Extensions.Logging /// Doesn't use ConfigurationBinder in order to allow ConfigurationBinder, and all its dependencies, /// to be trimmed. This improves app size and startup. /// - [UnsupportedOSPlatform("browser")] internal sealed class ConsoleLoggerConfigureOptions : IConfigureOptions { private readonly IConfiguration _configuration; + [UnsupportedOSPlatform("browser")] public ConsoleLoggerConfigureOptions(ILoggerProviderConfiguration providerConfiguration) { _configuration = providerConfiguration.Configuration; } - public void Configure(ConsoleLoggerOptions options) - { - if (ParseBool(_configuration, "DisableColors", out bool disableColors)) - { -#pragma warning disable CS0618 // Type or member is obsolete - options.DisableColors = disableColors; -#pragma warning restore CS0618 // Type or member is obsolete - } - -#pragma warning disable CS0618 // Type or member is obsolete - if (ParseEnum(_configuration, "Format", out ConsoleLoggerFormat format)) - { - options.Format = format; - } -#pragma warning restore CS0618 // Type or member is obsolete - - if (_configuration["FormatterName"] is string formatterName) - { - options.FormatterName = formatterName; - } - - if (ParseBool(_configuration, "IncludeScopes", out bool includeScopes)) - { -#pragma warning disable CS0618 // Type or member is obsolete - options.IncludeScopes = includeScopes; -#pragma warning restore CS0618 // Type or member is obsolete - } - - if (ParseEnum(_configuration, "LogToStandardErrorThreshold", out LogLevel logToStandardErrorThreshold)) - { - options.LogToStandardErrorThreshold = logToStandardErrorThreshold; - } - - if (ParseInt(_configuration, "MaxQueueLength", out int maxQueueLength)) - { - options.MaxQueueLength = maxQueueLength; - } - - if (ParseEnum(_configuration, "QueueFullMode", out ConsoleLoggerQueueFullMode queueFullMode)) - { - options.QueueFullMode = queueFullMode; - } - - if (_configuration["TimestampFormat"] is string timestampFormat) - { -#pragma warning disable CS0618 // Type or member is obsolete - options.TimestampFormat = timestampFormat; -#pragma warning restore CS0618 // Type or member is obsolete - } - - if (ParseBool(_configuration, "UseUtcTimestamp", out bool useUtcTimestamp)) - { -#pragma warning disable CS0618 // Type or member is obsolete - options.UseUtcTimestamp = useUtcTimestamp; -#pragma warning restore CS0618 // Type or member is obsolete - } - } - - /// - /// Parses the configuration value at the specified key into a bool. - /// - /// true if the value was successfully found and parsed. false if the key wasn't found. - /// Thrown when invalid data was found at the specified configuration key. - public static bool ParseBool(IConfiguration configuration, string key, out bool value) - { - if (configuration[key] is string valueString) - { - try - { - value = bool.Parse(valueString); - return true; - } - catch (Exception e) - { - ThrowInvalidConfigurationException(configuration, key, typeof(bool), e); - } - } - - value = default; - return false; - } - - /// - /// Parses the configuration value at the specified key into an enum. - /// - /// true if the value was successfully found and parsed. false if the key wasn't found. - /// Thrown when invalid data was found at the specified configuration key. - public static bool ParseEnum(IConfiguration configuration, string key, out T value) where T : struct - { - if (configuration[key] is string valueString) - { - try - { - value = -#if NETFRAMEWORK || NETSTANDARD2_0 - (T)Enum.Parse(typeof(T), valueString, ignoreCase: true); -#else - Enum.Parse(valueString, ignoreCase: true); -#endif - return true; - } - catch (Exception e) - { - ThrowInvalidConfigurationException(configuration, key, typeof(T), e); - } - } - - value = default; - return false; - } - - /// - /// Parses the configuration value at the specified key into an int. - /// - /// true if the value was successfully found and parsed. false if the key wasn't found. - /// Thrown when invalid data was found at the specified configuration key. - public static bool ParseInt(IConfiguration configuration, string key, out int value) - { - if (configuration[key] is string valueString) - { - try - { - value = int.Parse(valueString, NumberStyles.Integer, NumberFormatInfo.InvariantInfo); - return true; - } - catch (Exception e) - { - ThrowInvalidConfigurationException(configuration, key, typeof(int), e); - } - } - - value = default; - return false; - } - - private static void ThrowInvalidConfigurationException(IConfiguration configuration, string key, Type valueType, Exception innerException) - { - IConfigurationSection section = configuration.GetSection(key); - throw new InvalidOperationException(SR.Format(SR.InvalidConfigurationData, section.Path, valueType), innerException); - } + public void Configure(ConsoleLoggerOptions options) => options.Configure(_configuration); } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs index da4ff6bf0c991e..f4ffbe9309f301 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.Versioning; -using System.Text.Json; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -29,9 +28,9 @@ public static ILoggingBuilder AddConsole(this ILoggingBuilder builder) { builder.AddConfiguration(); - builder.AddConsoleFormatter(); + builder.AddConsoleFormatter(); builder.AddConsoleFormatter(); - builder.AddConsoleFormatter(); + builder.AddConsoleFormatter(); builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerOptions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerOptions.cs index 69704e4095a8eb..8b833ad6eff0e1 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerOptions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerOptions.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Globalization; +using Microsoft.Extensions.Configuration; namespace Microsoft.Extensions.Logging.Console { @@ -100,5 +102,146 @@ public int MaxQueueLength _maxQueuedMessages = value; } } + + internal void Configure(IConfiguration configuration) + { +#pragma warning disable CS0618 // Type or member is obsolete + if (ParseBool(configuration, nameof(DisableColors), out bool disableColors)) + { + DisableColors = disableColors; + } +#pragma warning restore CS0618 // Type or member is obsolete + +#pragma warning disable CS0618 // Type or member is obsolete + if (ParseEnum(configuration, nameof(Format), out ConsoleLoggerFormat format)) + { + Format = format; + } +#pragma warning restore CS0618 // Type or member is obsolete + + if (configuration[nameof(FormatterName)] is string formatterName) + { + FormatterName = formatterName; + } + +#pragma warning disable CS0618 // Type or member is obsolete + if (ParseBool(configuration, nameof(IncludeScopes), out bool includeScopes)) + { + IncludeScopes = includeScopes; + } +#pragma warning restore CS0618 // Type or member is obsolete + + if (ParseEnum(configuration, nameof(LogToStandardErrorThreshold), out LogLevel logToStandardErrorThreshold)) + { + LogToStandardErrorThreshold = logToStandardErrorThreshold; + } + + if (ParseInt(configuration, nameof(MaxQueueLength), out int maxQueueLength)) + { + MaxQueueLength = maxQueueLength; + } + + if (ParseEnum(configuration, nameof(QueueFullMode), out ConsoleLoggerQueueFullMode queueFullMode)) + { + QueueFullMode = queueFullMode; + } + +#pragma warning disable CS0618 // Type or member is obsolete + if (configuration[nameof(TimestampFormat)] is string timestampFormat) + { + TimestampFormat = timestampFormat; + } +#pragma warning restore CS0618 // Type or member is obsolete + +#pragma warning disable CS0618 // Type or member is obsolete + if (ParseBool(configuration, nameof(UseUtcTimestamp), out bool useUtcTimestamp)) + { + UseUtcTimestamp = useUtcTimestamp; + } +#pragma warning restore CS0618 // Type or member is obsolete + } + + /// + /// Parses the configuration value at the specified key into a bool. + /// + /// true if the value was successfully found and parsed. false if the key wasn't found. + /// Thrown when invalid data was found at the specified configuration key. + internal static bool ParseBool(IConfiguration configuration, string key, out bool value) + { + if (configuration[key] is string valueString) + { + try + { + value = bool.Parse(valueString); + return true; + } + catch (Exception e) + { + ThrowInvalidConfigurationException(configuration, key, typeof(bool), e); + } + } + + value = default; + return false; + } + + /// + /// Parses the configuration value at the specified key into an enum. + /// + /// true if the value was successfully found and parsed. false if the key wasn't found. + /// Thrown when invalid data was found at the specified configuration key. + internal static bool ParseEnum(IConfiguration configuration, string key, out T value) where T : struct + { + if (configuration[key] is string valueString) + { + try + { + value = +#if NETFRAMEWORK || NETSTANDARD2_0 + (T)Enum.Parse(typeof(T), valueString, ignoreCase: true); +#else + Enum.Parse(valueString, ignoreCase: true); +#endif + return true; + } + catch (Exception e) + { + ThrowInvalidConfigurationException(configuration, key, typeof(T), e); + } + } + + value = default; + return false; + } + + /// + /// Parses the configuration value at the specified key into an int. + /// + /// true if the value was successfully found and parsed. false if the key wasn't found. + /// Thrown when invalid data was found at the specified configuration key. + internal static bool ParseInt(IConfiguration configuration, string key, out int value) + { + if (configuration[key] is string valueString) + { + try + { + value = int.Parse(valueString, NumberStyles.Integer, NumberFormatInfo.InvariantInfo); + return true; + } + catch (Exception e) + { + ThrowInvalidConfigurationException(configuration, key, typeof(int), e); + } + } + + value = default; + return false; + } + + private static void ThrowInvalidConfigurationException(IConfiguration configuration, string key, Type valueType, Exception innerException) + { + IConfigurationSection section = configuration.GetSection(key); + throw new InvalidOperationException(SR.Format(SR.InvalidConfigurationData, section.Path, valueType), innerException); + } } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatterConfigureOptions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatterConfigureOptions.cs deleted file mode 100644 index acfb948f56a95b..00000000000000 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatterConfigureOptions.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.Versioning; -using System.Text.Json; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging.Configuration; -using Microsoft.Extensions.Logging.Console; -using Microsoft.Extensions.Options; - -namespace Microsoft.Extensions.Logging -{ - /// - /// Configures a JsonConsoleFormatterOptions object from an IConfiguration. - /// - /// - /// Doesn't use ConfigurationBinder in order to allow ConfigurationBinder, and all its dependencies, - /// to be trimmed. This improves app size and startup. - /// - [UnsupportedOSPlatform("browser")] - internal sealed class JsonConsoleFormatterConfigureOptions : IConfigureOptions - { - private readonly IConfiguration _configuration; - - public JsonConsoleFormatterConfigureOptions(ILoggerProviderConfiguration providerConfiguration) - { - _configuration = providerConfiguration.GetFormatterOptionsSection(); - } - - public void Configure(JsonConsoleFormatterOptions options) - { - ConsoleFormatterConfigureOptions.Bind(_configuration, options); - - if (_configuration.GetSection("JsonWriterOptions") is IConfigurationSection jsonWriterOptionsConfig) - { - JsonWriterOptions jsonWriterOptions = options.JsonWriterOptions; - - if (ConsoleLoggerConfigureOptions.ParseBool(jsonWriterOptionsConfig, "Indented", out bool indented)) - { - jsonWriterOptions.Indented = indented; - } - - if (ConsoleLoggerConfigureOptions.ParseInt(jsonWriterOptionsConfig, "MaxDepth", out int maxDepth)) - { - jsonWriterOptions.MaxDepth = maxDepth; - } - - if (ConsoleLoggerConfigureOptions.ParseBool(jsonWriterOptionsConfig, "SkipValidation", out bool skipValidation)) - { - jsonWriterOptions.SkipValidation = skipValidation; - } - - options.JsonWriterOptions = jsonWriterOptions; - } - } - } -} diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatterOptions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatterOptions.cs index 215e8598092f5f..2bdf51c67a8479 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatterOptions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatterOptions.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json; +using Microsoft.Extensions.Configuration; namespace Microsoft.Extensions.Logging.Console { @@ -19,5 +20,32 @@ public JsonConsoleFormatterOptions() { } /// Gets or sets JsonWriterOptions. /// public JsonWriterOptions JsonWriterOptions { get; set; } + + internal override void Configure(IConfiguration configuration) + { + base.Configure(configuration); + + if (configuration.GetSection(nameof(JsonWriterOptions)) is IConfigurationSection jsonWriterOptionsConfig) + { + JsonWriterOptions jsonWriterOptions = JsonWriterOptions; + + if (ConsoleLoggerOptions.ParseBool(jsonWriterOptionsConfig, nameof(JsonWriterOptions.Indented), out bool indented)) + { + jsonWriterOptions.Indented = indented; + } + + if (ConsoleLoggerOptions.ParseInt(jsonWriterOptionsConfig, nameof(JsonWriterOptions.MaxDepth), out int maxDepth)) + { + jsonWriterOptions.MaxDepth = maxDepth; + } + + if (ConsoleLoggerOptions.ParseBool(jsonWriterOptionsConfig, nameof(JsonWriterOptions.SkipValidation), out bool skipValidation)) + { + jsonWriterOptions.SkipValidation = skipValidation; + } + + JsonWriterOptions = jsonWriterOptions; + } + } } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatterConfigureOptions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatterConfigureOptions.cs deleted file mode 100644 index a8f9a6cf88f212..00000000000000 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatterConfigureOptions.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.Versioning; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging.Configuration; -using Microsoft.Extensions.Logging.Console; -using Microsoft.Extensions.Options; - -namespace Microsoft.Extensions.Logging -{ - /// - /// Configures a SimpleConsoleFormatterOptions object from an IConfiguration. - /// - /// - /// Doesn't use ConfigurationBinder in order to allow ConfigurationBinder, and all its dependencies, - /// to be trimmed. This improves app size and startup. - /// - [UnsupportedOSPlatform("browser")] - internal sealed class SimpleConsoleFormatterConfigureOptions : IConfigureOptions - { - private readonly IConfiguration _configuration; - - public SimpleConsoleFormatterConfigureOptions(ILoggerProviderConfiguration providerConfiguration) - { - _configuration = providerConfiguration.GetFormatterOptionsSection(); - } - - public void Configure(SimpleConsoleFormatterOptions options) - { - ConsoleFormatterConfigureOptions.Bind(_configuration, options); - - if (ConsoleLoggerConfigureOptions.ParseEnum(_configuration, "ColorBehavior", out LoggerColorBehavior colorBehavior)) - { - options.ColorBehavior = colorBehavior; - } - - if (ConsoleLoggerConfigureOptions.ParseBool(_configuration, "SingleLine", out bool singleLine)) - { - options.SingleLine = singleLine; - } - } - } -} diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatterOptions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatterOptions.cs index 2b32f919f94205..d31efbeda54e04 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatterOptions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatterOptions.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.Extensions.Configuration; + namespace Microsoft.Extensions.Logging.Console { /// @@ -22,5 +24,20 @@ public SimpleConsoleFormatterOptions() { } /// When , the entire message gets logged in a single line. /// public bool SingleLine { get; set; } + + internal override void Configure(IConfiguration configuration) + { + base.Configure(configuration); + + if (ConsoleLoggerOptions.ParseEnum(configuration, nameof(ColorBehavior), out LoggerColorBehavior colorBehavior)) + { + ColorBehavior = colorBehavior; + } + + if (ConsoleLoggerOptions.ParseBool(configuration, nameof(SingleLine), out bool singleLine)) + { + SingleLine = singleLine; + } + } } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs index 8202204fcf4bb8..0994980590122b 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs @@ -6,8 +6,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Reflection; -using System.Text.Json; using System.Text.RegularExpressions; using Microsoft.DotNet.RemoteExecutor; using Microsoft.Extensions.Configuration;