serilog-sinks-console icon indicating copy to clipboard operation
serilog-sinks-console copied to clipboard

Console's default output formatter renders `Properties:j` including type

Open zihotki opened this issue 5 years ago • 0 comments

Does this issue relate to a new feature or an existing bug?

  • [x] Bug
  • [ ] New Feature

What version of Serilog Console Sink is affected by this issue? Please list the related NuGet package. All, I assume

What is the target framework and operating system affected by this issue? Please see target frameworks & net standard matrix.

  • [x] netCore 2.0
  • [x] netCore 1.0
  • [x] 4.7
  • [x] 4.6.x
  • [x] 4.5.x

Please describe the current behaviour you are experiencing? When output template has {Properties:j} it renders complex types as {..., "$type": "..."}.

Please describe the expected behaviour if the ? Instead it should render it without $type or allow to override that behavior (also in config).

If the current behavior is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem NOTE: A small code sample goes a long way in expediting bug fixes or illustrating an enhancement you are proposing.

        public class HttpRequestInfo
        {
            public PathString Path { get; set; }
            public Dictionary<string, string> QueryString { get; set; }
        }

            Log.Logger = new LoggerConfiguration()
                            .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] <s:{SourceContext}> {Message:lj}{NewLine}{Exception}{NewLine}{Properties:j}{NewLine}")
                            .CreateLogger();

            Log.Logger.ForContext("info", new HttpRequestInfo { Path = "/hello"}, true)
                .Error("boom");

output sample:

[20:44:52 ERR] <s:> boom
{"info": {"Path": {"Value": "/hello", "HasValue": true, "$type": "PathString"} "$type": "HttpRequestInfo"}}

zihotki avatar Apr 22 '20 23:04 zihotki