a9bea183c1
- IContextualSerilogLogger<T> / ContextualSerilogLogger<T> in Services/Logging (handlers get a ForContext<T>-scoped logger via DI, consistent with ItemTracker) - SerilogRegistrar extension on WebApplicationBuilder (Api) - SerilogRegistrar extension on HostApplicationBuilder (Worker) - Both registrars: set Log.Logger, wire Logging + Host/Services, register ILogger singleton - ServiceCollectionExtensions: register IContextualSerilogLogger<> as transient - Program.cs in both apps simplified to single builder.AddSerilog() call Ref: IT-628 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
26 lines
755 B
C#
26 lines
755 B
C#
using HrynCo.NotificationService.Api;
|
|
using HrynCo.NotificationService.DAL.EF;
|
|
using HrynCo.NotificationService.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.AddSerilog();
|
|
|
|
var appSettings = builder.Configuration
|
|
.GetSection(AppSettings.SectionName)
|
|
.Get<AppSettings>() ?? throw new InvalidOperationException("App settings are not configured.");
|
|
|
|
builder.Services.AddSingleton(appSettings);
|
|
builder.Services.AddOpenApi();
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddNotificationDataAccess(appSettings.ConnectionString);
|
|
builder.Services.AddNotificationServices();
|
|
|
|
var app = builder.Build();
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
app.MapOpenApi();
|
|
|
|
app.UseHttpsRedirection();
|
|
app.MapControllers();
|
|
app.Run(); |