diff --git a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs index 00f4a8bf..1ec8a676 100644 --- a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs +++ b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs @@ -169,14 +169,10 @@ public static class ServiceCollectionExtensions var lockingBehavior = serviceProvider.GetRequiredService(); lockingBehavior.Initialise(opt); - // Enable SQL query logging when log level is Debug var loggerFactory = serviceProvider.GetService(); - if (loggerFactory != null) - { - opt.UseLoggerFactory(loggerFactory) - .EnableSensitiveDataLogging() - .EnableDetailedErrors(); - } + opt.UseLoggerFactory(loggerFactory) + .EnableSensitiveDataLogging() + .EnableDetailedErrors(); }); return serviceCollection; diff --git a/Jellyfin.Server/Resources/Configuration/logging.json b/Jellyfin.Server/Resources/Configuration/logging.json index 6462d791..066034d9 100644 --- a/Jellyfin.Server/Resources/Configuration/logging.json +++ b/Jellyfin.Server/Resources/Configuration/logging.json @@ -32,6 +32,32 @@ } ] } + }, + { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "File", + "Args": { + "path": "%JELLYFIN_LOG_DIR%//sql_.log", + "rollingInterval": "Day", + "retainedFileCountLimit": 3, + "rollOnFileSizeLimit": true, + "fileSizeLimitBytes": 100000000, + "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] [{ThreadId}] {SourceContext}: {Message}{NewLine}{Exception}" + } + } + ] + }, + "Filter": [ + { + "Name": "ByIncludingOnly", + "Args": { + "expression": "SourceContext = 'Microsoft.EntityFrameworkCore.Database.Command'" + } + } + ] } ], "Enrich": [ "FromLogContext", "WithThreadId" ]