using System; using System.IO; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using MudBlazor.Services; using Serilog; using Serilog.Formatting.Compact; using SharpRSS.Blazor.Data; using ToolQit; using ToolQit.Logging.Serilog; SetupSerilog(); var builder = WebApplication.CreateBuilder(args); builder.Logging.AddSerilog(); // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddScoped(); builder.Services.AddMudServices(); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.MapBlazorHub(); app.MapFallbackToPage("/_Host"); app.Run(); void SetupSerilog() { LoggerConfiguration _logConfig = new LoggerConfiguration() .Enrich.With(new LogEnricher()) .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} - {Sender} | {Level:u3}] {Message:lj}{NewLine}{Exception}") .WriteTo.File(new CompactJsonFormatter(), Path.Combine(Environment.CurrentDirectory, "logs", "log_.json"), rollingInterval: RollingInterval.Day); Log.Logger = _logConfig.CreateLogger(); LogManager.RegisterAdapter(new SerilogAdapter(Log.Logger)); }