-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (32 loc) · 1.25 KB
/
Copy pathProgram.cs
File metadata and controls
39 lines (32 loc) · 1.25 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
37
38
39
using System;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Serilog;
namespace YCodeLab
{
public class Program
{
public static void Main(string[] args)
{
var port = Environment.GetEnvironmentVariable("PORT");
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
var webHostBuilder = WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseSerilog((webHostBuilderContext, loggerConfiguration) =>
{
loggerConfiguration
.ReadFrom.Configuration(webHostBuilderContext.Configuration);
});
if (!string.IsNullOrEmpty(port))
webHostBuilder.UseUrls($"http://+:{port}");
Log.Logger.Information("PORT: {Port}", port);
//Log.Logger.Information("ASPNETCORE_URLS: {Port}", Environment.GetEnvironmentVariable("ASPNETCORE_URLS"));
//Log.Logger.Information("Urls setting in WebHost: {Port}", webHostBuilder.GetSetting(WebHostDefaults.ServerUrlsKey));
webHostBuilder
.Build()
.Run();
}
}
}