From 33a47f48c131d88da575cc53c306af36f330bb48 Mon Sep 17 00:00:00 2001 From: "OmegaLeo@Pebblehost" Date: Sun, 14 Dec 2025 17:24:00 +0000 Subject: [PATCH] Added Serilog --- .../Controllers/HomeController.cs | 2 +- .../OmegaLeo.HelperLib.Web.csproj | 3 +++ OmegaLeo.HelperLib.Web/Program.cs | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/OmegaLeo.HelperLib.Web/Controllers/HomeController.cs b/OmegaLeo.HelperLib.Web/Controllers/HomeController.cs index 88f7524..857b630 100644 --- a/OmegaLeo.HelperLib.Web/Controllers/HomeController.cs +++ b/OmegaLeo.HelperLib.Web/Controllers/HomeController.cs @@ -319,6 +319,6 @@ public class HomeController : Controller static string GetSolutionRoot() { - return Assembly.GetEntryAssembly().Location; + return AppContext.BaseDirectory; } } \ No newline at end of file diff --git a/OmegaLeo.HelperLib.Web/OmegaLeo.HelperLib.Web.csproj b/OmegaLeo.HelperLib.Web/OmegaLeo.HelperLib.Web.csproj index 1bd4652..96a5f1f 100644 --- a/OmegaLeo.HelperLib.Web/OmegaLeo.HelperLib.Web.csproj +++ b/OmegaLeo.HelperLib.Web/OmegaLeo.HelperLib.Web.csproj @@ -17,6 +17,9 @@ + + + diff --git a/OmegaLeo.HelperLib.Web/Program.cs b/OmegaLeo.HelperLib.Web/Program.cs index 56339e9..2a48945 100644 --- a/OmegaLeo.HelperLib.Web/Program.cs +++ b/OmegaLeo.HelperLib.Web/Program.cs @@ -1,11 +1,22 @@ +using Serilog; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); // Configure logging -builder.Logging.ClearProviders(); -builder.Logging.AddConsole(); +// Configure Serilog +Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .WriteTo.Console() + .WriteTo.File( + path: Path.Combine(AppContext.BaseDirectory, "logs", "documentation-.txt"), + rollingInterval: RollingInterval.Day, + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}") + .CreateLogger(); + +builder.Host.UseSerilog(); var app = builder.Build();