Debug/Release loglevel, title

This commit is contained in:
2023-08-02 08:38:18 +02:00
parent ed0abd9b6a
commit a97432e9c7
3 changed files with 16 additions and 7 deletions

View File

@@ -64,13 +64,15 @@ public static class Program
if (!Directory.Exists(logFolder)) Directory.CreateDirectory(logFolder);
Log.Logger = new LoggerConfiguration()
#if DEBUG || VERBOSE_LOGGING
.MinimumLevel.Verbose()
#endif
.Enrich.FromLogContext()
.WriteTo.File(
Path.Combine(logFolder, "appLog.log"),
fileSizeLimitBytes: 10 * 1024 * 1024,
rollOnFileSizeLimit: true,
rollingInterval: RollingInterval.Day)
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true)
.CreateBootstrapLogger();
}
@@ -82,9 +84,11 @@ public static class Program
{
#if DEBUG
InitDevelopment();
#else
InitRelease();
#endif
if (AppDataRoot is null)
{
InitRelease();
}
InitLogging();
Log.Logger.Information("Early app starting...");

View File

@@ -87,18 +87,20 @@ public static class Startup
(serviceProvider, loggerConfiguration) =>
{
loggerConfiguration
#if DEBUG || VERBOSE_LOGGING
.MinimumLevel.Verbose()
#endif
.ReadFrom.Configuration(serviceProvider.GetRequiredService<IConfiguration>())
.Enrich.FromLogContext()
.WriteTo.File(
Path.Combine(Program.AppDataRoot, "logs", "appLog.log"),
fileSizeLimitBytes: 10 * 1024 * 1024,
rollOnFileSizeLimit: true,
rollingInterval: RollingInterval.Day)
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true)
.WriteTo.Sink(serviceProvider.GetRequiredService<ToastMessageSink>());
}
);
serviceCollection.AddLogging(loggingBuilder =>
loggingBuilder.AddSerilog(dispose: true)
);

View File

@@ -55,6 +55,9 @@ public partial class MainWindowViewModel : IMainWindowViewModel
}
Title = "FileTime " + versionString;
#if DEBUG
Title += " (Debug)";
#endif
Task.Run(async () => await _lifecycleService.InitStartupHandlersAsync()).Wait();
}