From c3c85bc10eba802846540fe00a477cc7dbdbba34 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Tue, 31 Dec 2024 17:37:17 +0100 Subject: [PATCH] Do not log dataprotection warnings to database log but keep for filelog (#493) --- src/Utilities/AliasVault.Logging/LoggingConfiguration.cs | 8 ++++++-- .../DataProtectionExtensions.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Utilities/AliasVault.Logging/LoggingConfiguration.cs b/src/Utilities/AliasVault.Logging/LoggingConfiguration.cs index f108e5e86..4752ef149 100644 --- a/src/Utilities/AliasVault.Logging/LoggingConfiguration.cs +++ b/src/Utilities/AliasVault.Logging/LoggingConfiguration.cs @@ -56,11 +56,15 @@ public static class LoggingConfiguration rollingInterval: RollingInterval.Day, outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}")) - // Log all warning and above to database via EF core except for Microsoft.EntityFrameworkCore logs - // as this would create a loop. + // Log all warning and above to database via EF core except for: + // - Microsoft.EntityFrameworkCore logsas this would create a loop. + // - Microsoft.AspNetCore.Antiforgery logs + // - Microsoft.AspNetCore.DataProtection logs .WriteTo.Logger(lc => lc .Filter.ByIncludingOnly(evt => evt.Level >= LogEventLevel.Warning) .Filter.ByExcluding(Matching.FromSource("Microsoft.EntityFrameworkCore")) + .Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.Antiforgery")) + .Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.DataProtection")) .WriteTo.Sink(new DatabaseSink(CultureInfo.InvariantCulture, () => services.BuildServiceProvider().GetRequiredService>(), applicationName))) .CreateLogger()); diff --git a/src/Utilities/Cryptography/AliasVault.Cryptography.Server/DataProtectionExtensions.cs b/src/Utilities/Cryptography/AliasVault.Cryptography.Server/DataProtectionExtensions.cs index eeb615fe7..bca3f18bc 100644 --- a/src/Utilities/Cryptography/AliasVault.Cryptography.Server/DataProtectionExtensions.cs +++ b/src/Utilities/Cryptography/AliasVault.Cryptography.Server/DataProtectionExtensions.cs @@ -52,8 +52,8 @@ public static class DataProtectionExtensions } services.AddDataProtection() - .ProtectKeysWithCertificate(cert) .PersistKeysToDbContext() + .ProtectKeysWithCertificate(cert) .SetApplicationName(applicationName); return services;