Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
  3.  
  4.  
  5. using Microsoft.AspNetCore.Hosting;
  6. using Microsoft.Extensions.Hosting;
  7. using Serilog;
  8. using Serilog.Events;
  9. using Serilog.Sinks.SystemConsole.Themes;
  10. using System;
  11.  
  12. namespace IdentityServer
  13. {
  14. public class Program
  15. {
  16. public static int Main(string[] args)
  17. {
  18. Log.Logger = new LoggerConfiguration()
  19. .MinimumLevel.Debug()
  20. .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
  21. .MinimumLevel.Override("System", LogEventLevel.Warning)
  22. .MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
  23. .Enrich.FromLogContext()
  24. // uncomment to write to Azure diagnostics stream
  25. //.WriteTo.File(
  26. // @"D:\home\LogFiles\Application\identityserver.txt",
  27. // fileSizeLimitBytes: 1_000_000,
  28. // rollOnFileSizeLimit: true,
  29. // shared: true,
  30. // flushToDiskInterval: TimeSpan.FromSeconds(1))
  31. .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate)
  32. .CreateLogger();
  33.  
  34. try
  35. {
  36. Log.Information("Starting host...");
  37. CreateHostBuilder(args).Build().Run();
  38. return 0;
  39. }
  40. catch (Exception ex)
  41. {
  42. Log.Fatal(ex, "Host terminated unexpectedly.");
  43. return 1;
  44. }
  45. finally
  46. {
  47. Log.CloseAndFlush();
  48. }
  49. }
  50.  
  51. public static IHostBuilder CreateHostBuilder(string[] args) =>
  52. Host.CreateDefaultBuilder(args)
  53. .ConfigureWebHostDefaults(webBuilder =>
  54. {
  55. webBuilder.UseUrls("http://localhost:4999");
  56. webBuilder.UseStartup<Startup>();
  57. webBuilder.UseSerilog();
  58. });
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement