12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using Hotline.Api;
- using Serilog;
- Log.Logger = new LoggerConfiguration()
- .WriteTo.Console()
- .CreateBootstrapLogger();
- try
- {
- Log.Information("Hotline service is Starting up");
- var builder = WebApplication.CreateBuilder(args);
- builder.Host
- .ConfigureAppConfiguration((hostBuilderContext, configBuilder) =>
- {
- var path = Path.Combine(Directory.GetCurrentDirectory(), "config");
- configBuilder.SetBasePath(path)
- #if DEBUG
- .AddJsonFile("appsettings.shared.Development.json", true, true)
- #else
- .AddJsonFile("appsettings.shared.json", true, true)
- #endif
- .AddJsonFile("appsettings.json", false, true)
- .AddJsonFile($"appsettings.{hostBuilderContext.HostingEnvironment.EnvironmentName}.json", true, true)
- .AddEnvironmentVariables()
- .AddCommandLine(args)
- ;
- })
- .UseSerilog((ctx, lc) => lc
- //.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}")
- .Enrich.FromLogContext()
- .ReadFrom.Configuration(ctx.Configuration), true)
- ;
- builder
- .ConfigureServices()
- .ConfigurePipelines()
- .Run();
- }
- catch (Exception ex)
- {
- Log.Fatal(ex, "Unhandled exception");
- }
- finally
- {
- Log.Information("Shut down complete");
- Log.CloseAndFlush();
- }
|