Make WriteDiagnosticsToLog additive to the file or custom diagnostic writer#7722
Conversation
| var logDictionary = new Dictionary<string, object>(dictionary, StringComparer.OrdinalIgnoreCase); | ||
| // Always compact AssemblyScanning section when writing to log | ||
| if (logDictionary.TryGetValue(AssemblyScanningDiagnostics.SectionName, out var assemblyScanningSection) && | ||
| assemblyScanningSection is AssemblyScanningDiagnostics assemblyScanningDiagnostics) |
There was a problem hiding this comment.
Won't logDictionary always be a newly created dictionary and so logDictionary.TryGetValue() always return false?
I have to admit I am struggling to see (aside from this small bit) where this PR isn't just reorganizing some nesting levels and try/catch barriers. I don't understand how it's making anything additive. I have to be missing something.
There was a problem hiding this comment.
@DavidBoike The dictionary is a copy containing the values of the root dictionary created above which contains all the sections.
I don't understand how it's making anything additive. I have to be missing something.
Previously there was a return statement in there.
There was a problem hiding this comment.
Ah, I see the difference now. Thanks!
Follow up on #7660
As part of the work for Azure Functions we realize there are valid reasons to override the custom diagnostic writer to, for example, write the full information to blob storage and optionally write it to the log.
This is why we are making writing to log additive instead of exclusive. The functions default will disable the file writing by providing a no-op writer and customers can then opt-into custom writer themselves and/or writing to the logs.