mirror of
https://github.com/Azure/DotNetty.git
synced 2026-10-20 23:55:54 +08:00
1cdaadbfaa
- microsoft.extensions.logging 5.0.0 - microsoft.extensions.configuration 5.0.0
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
namespace Examples.Common
|
|
{
|
|
using System;
|
|
using DotNetty.Common.Internal.Logging;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
public static class ExampleHelper
|
|
{
|
|
static ExampleHelper()
|
|
{
|
|
Configuration = new ConfigurationBuilder()
|
|
.SetBasePath(ProcessDirectory)
|
|
.AddJsonFile("appsettings.json")
|
|
.Build();
|
|
}
|
|
|
|
public static string ProcessDirectory
|
|
{
|
|
get
|
|
{
|
|
#if NETSTANDARD2_0
|
|
return AppContext.BaseDirectory;
|
|
#else
|
|
return AppDomain.CurrentDomain.BaseDirectory;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public static IConfigurationRoot Configuration { get; }
|
|
|
|
public static void SetConsoleLogger() => InternalLoggerFactory.DefaultFactory = LoggerFactory.Create(builder => builder.AddConsole());
|
|
}
|
|
} |