Program.cs 741 B

1234567891011121314151617181920212223242526272829303132
  1. using CallCenter.Api;
  2. using Serilog;
  3. Log.Logger = new LoggerConfiguration()
  4. .WriteTo.Console()
  5. .CreateBootstrapLogger();
  6. Log.Information("Starting up");
  7. try
  8. {
  9. var builder = WebApplication.CreateBuilder(args);
  10. builder.Host.UseSerilog((ctx, lc) => lc
  11. //.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}")
  12. .Enrich.FromLogContext()
  13. .ReadFrom.Configuration(ctx.Configuration));
  14. builder
  15. .ConfigureServices()
  16. .ConfigurePipelines()
  17. .Run();
  18. }
  19. catch (Exception ex)
  20. {
  21. Log.Fatal(ex, "Unhandled exception");
  22. }
  23. finally
  24. {
  25. Log.Information("Shut down complete");
  26. Log.CloseAndFlush();
  27. }