some OP
This commit is contained in:
		| @@ -1,3 +1,5 @@ | ||||
| using System.Collections.Immutable; | ||||
| using System.Buffers; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| @@ -7,6 +9,7 @@ using Microsoft.AspNetCore.Hosting; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Microsoft.Extensions.Hosting; | ||||
| using Microsoft.Extensions.Logging; | ||||
| using OpenTelemetry.Logs; | ||||
| using Serilog; | ||||
|  | ||||
| namespace FwSearchApi | ||||
| @@ -21,22 +24,31 @@ namespace FwSearchApi | ||||
|  | ||||
|         public static void Main(string[] args) | ||||
|         { | ||||
|             Log.Logger = new LoggerConfiguration() | ||||
|                 .ReadFrom.Configuration(Configuration) | ||||
|                 .CreateLogger(); | ||||
|             try { | ||||
|                 CreateWebHostBuilder(args).Build().Run(); | ||||
|             } | ||||
|             finally{ | ||||
|                 Log.CloseAndFlush(); | ||||
|             } | ||||
|             CreateHostBuilder(args).Build().Run(); | ||||
|         } | ||||
|  | ||||
|         public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | ||||
|             WebHost.CreateDefaultBuilder(args) | ||||
|                     .UseConfiguration(Configuration) | ||||
|                     .UseStartup<Startup>() | ||||
|                     .UseSerilog() | ||||
|                     .SuppressStatusMessages(true); | ||||
|         public static IHostBuilder CreateHostBuilder(string[] args) => | ||||
|             Host.CreateDefaultBuilder(args) | ||||
|                 .ConfigureWebHostDefaults(webBuilder =>  | ||||
|                 { | ||||
|                     webBuilder.UseStartup<Startup>(); | ||||
|                     webBuilder.UseConfiguration(Configuration); | ||||
|                 }) | ||||
|                 .ConfigureLogging((context, builder) => | ||||
|                 { | ||||
|                     builder.ClearProviders(); | ||||
|                     builder.AddConsole(); | ||||
|  | ||||
|                     builder.AddOpenTelemetry(options => | ||||
|                     { | ||||
|                         options.IncludeScopes = true; | ||||
|                         options.ParseStateValues = true; | ||||
|                         options.IncludeFormattedMessage = true; | ||||
|                         options.AddConsoleExporter(); | ||||
|                     }); | ||||
|                      | ||||
|                 }); | ||||
|          | ||||
|              | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user