-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
67 lines (58 loc) · 2.54 KB
/
Program.cs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Runtime.InteropServices;
using Gelf.Extensions.Logging;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace NotificationServer
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); })
.ConfigureLogging(ConfigureLogging)
.UseWindowsService();
}
private static void ConfigureLogging(HostBuilderContext context, ILoggingBuilder builder)
{
var configuration = context.Configuration;
// <see cref="https://github.com/mattwcole/gelf-extensions-logging"/>
// Read GelfLoggerOptions from appsettings.json
var session = configuration.GetSection("Graylog");
builder.Services.Configure<GelfLoggerOptions>(session);
// Optionally configure GelfLoggerOptions further.
builder.Services.PostConfigure<GelfLoggerOptions>(options =>
{
options.AdditionalFields["machine-name"] = Environment.MachineName;
options.AdditionalFields["operation-system"] = RuntimeInformation.OSDescription;
});
// Read Logging settings from appsettings.json and add providers.
builder.AddConfiguration(configuration.GetSection("Logging"))
.AddGelf();
}
#region MyRegion
//private static void Options(KestrelServerOptions o)
//{
// o.Limits.MaxConcurrentConnections = null;
// o.Limits.MaxConcurrentUpgradedConnections = null;
// o.Limits.MaxRequestBufferSize = null;
// o.Limits.MaxRequestHeaderCount = 4096;
// o.Limits.MaxRequestHeadersTotalSize = 32768 * o.Limits.MaxRequestHeaderCount;
// // <see cref="https://stackoverflow.com/a/47112438"/>
// o.Limits.MaxRequestBodySize = null;
// // <see cref="https://stackoverflow.com/a/47809150"/>
// // o.Limits.KeepAliveTimeout = TimeSpan.FromHours(1);
// // o.Limits.RequestHeadersTimeout = TimeSpan.FromHours(1);
// o.Limits.MaxResponseBufferSize = null;
// o.AddServerHeader = false;
//}
#endregion
}
}