|
|
|
@ -1,13 +1,45 @@ |
|
|
|
using System; |
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
using Microsoft.Extensions.Hosting; |
|
|
|
using Serilog; |
|
|
|
using Serilog.Events; |
|
|
|
|
|
|
|
namespace MyCompanyName.MyProjectName.Blazor.Server |
|
|
|
{ |
|
|
|
public class Program |
|
|
|
{ |
|
|
|
public static void Main(string[] args) |
|
|
|
public static int Main(string[] args) |
|
|
|
{ |
|
|
|
CreateHostBuilder(args).Build().Run(); |
|
|
|
Log.Logger = new LoggerConfiguration() |
|
|
|
#if DEBUG
|
|
|
|
.MinimumLevel.Debug() |
|
|
|
#else
|
|
|
|
.MinimumLevel.Information() |
|
|
|
#endif
|
|
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
|
|
|
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
|
|
|
.Enrich.FromLogContext() |
|
|
|
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
|
|
|
#if DEBUG
|
|
|
|
.WriteTo.Async(c => c.Console()) |
|
|
|
#endif
|
|
|
|
.CreateLogger(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
Log.Information("Starting web host."); |
|
|
|
CreateHostBuilder(args).Build().Run(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
Log.CloseAndFlush(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) => |
|
|
|
@ -16,6 +48,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server |
|
|
|
{ |
|
|
|
webBuilder.UseStartup<Startup>(); |
|
|
|
}) |
|
|
|
.UseAutofac(); |
|
|
|
.UseAutofac() |
|
|
|
.UseSerilog(); |
|
|
|
} |
|
|
|
} |
|
|
|
|