Update base path for configuration loading
Replaced `Directory.GetCurrentDirectory()` with `AppContext.BaseDirectory` in `Program.cs` to set the base path for configuration loading. This ensures configuration files are loaded relative to the application's runtime location instead of the current working directory.
This commit is contained in:
@@ -8,10 +8,10 @@ using Serilog.Ui.Web.Extensions;
|
||||
|
||||
// Build temporary configuration to read log directory early
|
||||
var tempConfig = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
|
||||
.AddJsonFile("appsettings.Secrets.json", optional: true, reloadOnChange: false)
|
||||
.Build();
|
||||
.SetBasePath(AppContext.BaseDirectory)
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
|
||||
.AddJsonFile("appsettings.Secrets.json", optional: true, reloadOnChange: false)
|
||||
.Build();
|
||||
|
||||
var logDirectoryRaw = tempConfig.GetValue<string>("Application:LogDirectory") ?? "logs";
|
||||
// Always resolve to an absolute path so sink and UI provider point to the same file
|
||||
|
||||
Reference in New Issue
Block a user