-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
36 lines (35 loc) · 1.29 KB
/
Program.cs
File metadata and controls
36 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using GenericHostConsoleApp.Services;
internal class Program
{
/// <summary>
/// プログラムエントリポイント
/// </summary>
/// <param name="args">コマンドライン引数</param>
private static async Task Main(string[] args)
{
await Host.CreateDefaultBuilder()
.ConfigureAppConfiguration((context, config) =>
{
config.SetBasePath(Path.GetDirectoryName(Environment.ProcessPath));
config.AddJsonFile("appsettings2.json", optional: true);
config.AddJsonFile("nlog.json", optional: true);
})
.ConfigureLogging((context, logging) =>
{
logging.ClearProviders();
logging.AddNLog(new NLogLoggingConfiguration(context.Configuration.GetSection("NLog")));
})
.ConfigureServices((context, services) =>
{
services.AddHostedService<ExampleHostedService>();
services.AddHostedService<ExampleBackgroundHostedService>();
})
.Build()
.RunAsync();
}
}