You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
A bad designed Class can cause an Exception when logging with stringification operator. Using the JsonFormatter or a Formatter that uses the JsonValueFormatter internally like CompactJsonFormatter or RenderedCompactJsonFormatter.
Reproduction
Log using stringification operator with a instance of a class that can return null in ToString(). With configured to use JsonFormatter or CompactJsonFormatter or RenderedCompactJsonFormatter.
Log.Logger=newLoggerConfiguration().WriteTo.Console(newSerilog.Formatting.Json.JsonFormatter())//Or other JsonFormatter.CreateLogger();classABadBehavior{publicoverridestringToString()=>null;}Log.Information("{$Data}",newABadBehavior());
Expected behavior
That the Serilog Core doesn't throw an exception. And Log the result like was another null property.
Relevant package, tooling and runtime versions
All runtimes and using the lastest Serilog codebase.
Additional context
I find this issue when implementing the C#8 Nullable Reference Type in Serilog codebase.
Related Issue #1426