From 1e9e4ffda9abe30b71ceb1de2f4c3143805c66a9 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Mon, 9 Jun 2025 04:52:39 +0300 Subject: Rework startup topic handling and reenable output to logging framework (#14243) --- Jellyfin.Server/Program.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Jellyfin.Server/Program.cs') diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 0b77d63ac7..dc7fa5eb36 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -60,7 +60,7 @@ namespace Jellyfin.Server private static long _startTimestamp; private static ILogger _logger = NullLogger.Instance; private static bool _restartOnShutdown; - private static IStartupLogger? _migrationLogger; + private static IStartupLogger? _migrationLogger; private static string? _restoreFromBackup; /// @@ -103,6 +103,7 @@ namespace Jellyfin.Server _setupServer = new SetupServer(static () => _jellyfinHost?.Services?.GetService(), appPaths, static () => _appHost, _loggerFactory, startupConfig); await _setupServer.RunAsync().ConfigureAwait(false); _logger = _loggerFactory.CreateLogger("Main"); + StartupLogger.Logger = new StartupLogger(_logger); // Use the logging framework for uncaught exceptions instead of std error AppDomain.CurrentDomain.UnhandledException += (_, e) @@ -178,7 +179,9 @@ namespace Jellyfin.Server }) .ConfigureAppConfiguration(config => config.ConfigureAppConfiguration(options, appPaths, startupConfig)) .UseSerilog() - .ConfigureServices(e => e.AddTransient().AddSingleton(e)) + .ConfigureServices(e => e + .RegisterStartupLogger() + .AddSingleton(e)) .Build(); // Re-use the host service provider in the app host since ASP.NET doesn't allow a custom service collection. @@ -268,7 +271,7 @@ namespace Jellyfin.Server /// A task. public static async Task ApplyStartupMigrationAsync(ServerApplicationPaths appPaths, IConfiguration startupConfig) { - _migrationLogger = StartupLogger.Logger.BeginGroup($"Migration Service"); + _migrationLogger = StartupLogger.Logger.BeginGroup($"Migration Service"); var startupConfigurationManager = new ServerConfigurationManager(appPaths, _loggerFactory, new MyXmlSerializer()); startupConfigurationManager.AddParts([new DatabaseConfigurationFactory()]); var migrationStartupServiceProvider = new ServiceCollection() @@ -276,7 +279,7 @@ namespace Jellyfin.Server .AddJellyfinDbContext(startupConfigurationManager, startupConfig) .AddSingleton(appPaths) .AddSingleton(appPaths) - .AddSingleton(_migrationLogger); + .RegisterStartupLogger(); migrationStartupServiceProvider.AddSingleton(migrationStartupServiceProvider); var startupService = migrationStartupServiceProvider.BuildServiceProvider(); -- cgit v1.2.3