Add WriteTo.FallbackChain and WriteTo.Fallible support in configuration#474
Merged
nblumhardt merged 2 commits intoserilog:devfrom Apr 30, 2026
Merged
Conversation
FallbackChain and Fallible were introduced as instance methods on LoggerSinkConfiguration in Serilog 4.1, so they weren't discovered by the extension-method scanner. Expose them through the same surrogate pattern already used for Sink/Logger. Sample project demonstrates both features against an AlwaysFailingSink so the fallback path and failure listener are actually exercised at runtime. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mention Conditional/FallbackChain/Fallible in the nested-configuration section of the README, and extend the sample appsettings.json with WithComputed, ByExcluding, ExpressionTemplate, AuditTo, and a MinimumLevel ControlledBy switch to exercise more of the supported surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nblumhardt
approved these changes
Apr 30, 2026
Member
nblumhardt
left a comment
There was a problem hiding this comment.
Looks good, thanks @ArieGato.
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #473.
Summary
FallbackChainandFalliblesurrogates toSurrogateConfigurationMethodsso the twoLoggerSinkConfigurationinstance methods introduced in Serilog 4.1 can be used fromappsettings.json/IConfiguration.Sampleproject with anAlwaysFailingSinkplus aSampleFailureListenerso both sections in the sampleappsettings.jsonexercise the fallback path and failure-listener path at runtime.paramsarray, andFalliblerouting failures to a listener.Implementation notes
Both methods are instance methods on
LoggerSinkConfigurationrather than extension methods, so the extension-method scanner inConfigurationReader.FindConfigurationExtensionMethodsdoesn't discover them — same as the existingSink/Loggersurrogates.FallbackChain's third parameter isparams Action<LoggerSinkConfiguration>[]. Becauseparamsdoes not setParameterInfo.HasDefaultValue = true, it isn't treated as omittable byHasImplicitValueWhenNotSpecified, so the surrogate uses= nullexplicitly. Same underlying mechanical issue as #441; that broader fix would let the surrogate drop the?? []workaround later.LoggerAuditSinkConfigurationdoes not expose these methods in Serilog (by design — audit pipelines are meant to fail loudly), so no correspondingAuditTosurrogates are added.Test plan
dotnet buildpasses on net462 / netstandard2.0 / net8.0 / net9.0 / net10.0coverlet.collectorlocally)[fallback ...]lines in console and[SampleFailureListener]lines inSelfLog)