Browse Source

Remove Serilog from Web.Shopping.HttpAggregator

davidfowl/common-services
Reuben Bond 1 year ago
parent
commit
7d28625959
3 changed files with 3 additions and 40 deletions
  1. +0
    -2
      src/ApiGateways/Web.Bff.Shopping/aggregator/GlobalUsings.cs
  2. +3
    -36
      src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs
  3. +0
    -2
      src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj

+ 0
- 2
src/ApiGateways/Web.Bff.Shopping/aggregator/GlobalUsings.cs View File

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

+ 3
- 36
src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs View File

@ -1,6 +1,6 @@
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration));
builder.Logging.AddConsole();
builder.Services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(builder.Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
@ -21,6 +21,7 @@ else
{
app.UseExceptionHandler("/Home/Error");
}
var pathBase = builder.Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase))
{
@ -56,41 +57,7 @@ app.MapHealthChecks("/liveness", new HealthCheckOptions
Predicate = r => r.Name.Contains("self")
});
try
{
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);
}
await app.RunAsync();
public static class ServiceCollectionExtensions
{


+ 0
- 2
src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj View File

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


Loading…
Cancel
Save