Skip to content

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

@zihotki

Description

@zihotki

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

  • 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.

  • netCore 2.0
  • netCore 1.0
  • 4.7
  • 4.6.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"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions