THRIFT-4824 Logger deprecation warnings in tutorial
Client: netstd
Patch: Jens Geyer
this closes #1760
diff --git a/tutorial/netstd/Client/Program.cs b/tutorial/netstd/Client/Program.cs
index bf35746..4b68cee 100644
--- a/tutorial/netstd/Client/Program.cs
+++ b/tutorial/netstd/Client/Program.cs
@@ -31,12 +31,14 @@
using Thrift.Transport.Client;
using tutorial;
using shared;
+using Microsoft.Extensions.DependencyInjection;
namespace Client
{
public class Program
{
- private static readonly ILogger Logger = new LoggerFactory().AddConsole().AddDebug().CreateLogger(nameof(Client));
+ private static ServiceCollection ServiceCollection = new ServiceCollection();
+ private static ILogger Logger;
private static void DisplayHelp()
{
@@ -75,6 +77,9 @@
{
args = args ?? new string[0];
+ ServiceCollection.AddLogging(logging => ConfigureLogging(logging));
+ Logger = ServiceCollection.BuildServiceProvider().GetService<ILoggerFactory>().CreateLogger(nameof(Client));
+
if (args.Any(x => x.StartsWith("-help", StringComparison.OrdinalIgnoreCase)))
{
DisplayHelp();
@@ -89,6 +94,13 @@
}
}
+ private static void ConfigureLogging(ILoggingBuilder logging)
+ {
+ logging.SetMinimumLevel(LogLevel.Trace);
+ logging.AddConsole();
+ logging.AddDebug();
+ }
+
private static async Task RunAsync(string[] args, CancellationToken cancellationToken)
{
var numClients = GetNumberOfClients(args);