Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

59 rindas
1.8 KiB

  1. using Microsoft.AspNetCore.Hosting;
  2. using Microsoft.Extensions.Configuration;
  3. using Microsoft.Extensions.Hosting;
  4. using Serilog;
  5. using Serilog.Events;
  6. using System;
  7. namespace Sample.RabbitMQ.SqlServer.DispatcherPerGroup
  8. {
  9. public class Program
  10. {
  11. public static int Main(string[] args)
  12. {
  13. Log.Logger = new LoggerConfiguration()
  14. .MinimumLevel.Debug()
  15. .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
  16. .Enrich.FromLogContext()
  17. .WriteTo.Debug()
  18. #if DEBUG
  19. .WriteTo.Seq("http://localhost:5341")
  20. #endif
  21. .CreateLogger();
  22. try
  23. {
  24. Log.Information("Starting host...");
  25. CreateHostBuilder(args).Build().Run();
  26. return 0;
  27. }
  28. catch (Exception ex)
  29. {
  30. Log.Fatal(ex.InnerException ?? ex, "Host terminated unexpectedly");
  31. return 1;
  32. }
  33. finally
  34. {
  35. Log.CloseAndFlush();
  36. }
  37. }
  38. public static IHostBuilder CreateHostBuilder(string[] args) =>
  39. Host.CreateDefaultBuilder(args)
  40. .ConfigureAppConfiguration((context, builder) =>
  41. {
  42. builder
  43. .AddJsonFile("appsettings.json")
  44. .AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", true);
  45. })
  46. .UseSerilog((context, configuration) =>
  47. {
  48. configuration.ReadFrom.Configuration(context.Configuration);
  49. }, true, true)
  50. .ConfigureWebHostDefaults(webBuilder =>
  51. {
  52. webBuilder.UseStartup<Startup>();
  53. });
  54. }
  55. }