From 4ac94d1ff2d908bfb415f9f04b9d5ca9422bbf19 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 17 Aug 2026 02:08:57 +0000 Subject: [PATCH] Say AsScalar instead of restating ToString Same output, but it states the intent: leave a SecretString whole rather than transform it. The comment now separates the two lines by what they do, because they are not the same kind of thing - the policy is the protection, and without it a masked object is written out property by property, while this line only decides whether a secret reads as its length or as {"HasValue":true}. Co-authored-by: rmcrackan --- Source/LibationFileManager/Configuration.Logging.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/LibationFileManager/Configuration.Logging.cs b/Source/LibationFileManager/Configuration.Logging.cs index d0c5cf9b..71c598ed 100644 --- a/Source/LibationFileManager/Configuration.Logging.cs +++ b/Source/LibationFileManager/Configuration.Logging.cs @@ -163,10 +163,12 @@ public partial class Configuration .ReadFrom.Configuration(configuration, readerOptions) .Destructure.ByTransforming(lp => lp.Path) .Destructure.With() - // last lines of defense for structured logging: a masked identity instead of the object, and a - // secret that renders as its shape instead of its contents + // protection: without this, an ILogMasked logged as {@Account} is written out property by property .Destructure.With() - .Destructure.ByTransforming(secret => secret.ToString()) + // legibility rather than protection. A SecretString is already safe wherever it lands - it has no + // public member holding the value - but asking Serilog to take one apart yields + // {"HasValue":true,"$type":"SecretString"} instead of the length, so tell Serilog to leave it whole. + .Destructure.AsScalar() .CreateLogger(); SerilogInitialized = true; }