Remove Serilog from Web.Shopping.HttpAggregator

This commit is contained in:
Reuben Bond 2023-05-04 07:52:40 -07:00
parent d96e4db08c
commit 7d28625959
3 changed files with 3 additions and 40 deletions

View File

@ -24,7 +24,6 @@ global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options; global using Microsoft.Extensions.Options;
global using Microsoft.OpenApi.Models; global using Microsoft.OpenApi.Models;
global using Serilog;
global using Swashbuckle.AspNetCore.SwaggerGen; global using Swashbuckle.AspNetCore.SwaggerGen;
global using System.Collections.Generic; global using System.Collections.Generic;
global using System.IdentityModel.Tokens.Jwt; global using System.IdentityModel.Tokens.Jwt;
@ -37,4 +36,3 @@ global using System.Threading.Tasks;
global using System.Threading; global using System.Threading;
global using System; global using System;
global using Microsoft.IdentityModel.Tokens; global using Microsoft.IdentityModel.Tokens;
global using Serilog.Context;

View File

@ -1,6 +1,6 @@
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration)); builder.Logging.AddConsole();
builder.Services.AddHealthChecks() builder.Services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy()) .AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(builder.Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" }) .AddUrlGroup(new Uri(builder.Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
@ -21,6 +21,7 @@ else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
} }
var pathBase = builder.Configuration["PATH_BASE"]; var pathBase = builder.Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
@ -56,41 +57,7 @@ app.MapHealthChecks("/liveness", new HealthCheckOptions
Predicate = r => r.Name.Contains("self") Predicate = r => r.Name.Contains("self")
}); });
try await app.RunAsync();
{
Log.Information("Starts Web Application ({ApplicationContext})...", Program.AppName);
await app.RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName);
return 1;
}
finally
{
Log.CloseAndFlush();
}
Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
{
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
var logstashUrl = configuration["Serilog:LogstashgUrl"];
return new LoggerConfiguration()
.MinimumLevel.Verbose()
.Enrich.WithProperty("ApplicationContext", Program.AppName)
.Enrich.FromLogContext()
.WriteTo.Console()
.ReadFrom.Configuration(configuration)
.CreateLogger();
}
public partial class Program
{
public static string Namespace = typeof(Program).Assembly.GetName().Name;
public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
}
public static class ServiceCollectionExtensions public static class ServiceCollectionExtensions
{ {

View File

@ -26,8 +26,6 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" /> <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="Serilog.AspNetCore" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Swashbuckle.AspNetCore" /> <PackageReference Include="Swashbuckle.AspNetCore" />
</ItemGroup> </ItemGroup>