Visitar URL original
JsonSerializer could have an option to include serialization of Fields · Issue #3920 · NLog/NLog · GitHub
Skip to content

JsonSerializer could have an option to include serialization of Fields #3920

Open

Description

@snakefoot

Have this exciting discussion about how to bend an old application to support structured logging:

https://stackoverflow.com/questions/61281449/set-valueformatter-for-specific-nlog-instance

There are some places where NLog could be more helpful for this scenario:

  • When replacing the JsonSerializer with a custom one, then one doesn't actually get to know the configured MaxRecursionLimit on the JsonLayout. I think it would make sense that the JsonLayout skips calling the JsonSerializer for "unknown" objects when MaxRecursionLimit=0. But instead just performs a ToString-operation (Unknown objects are those that doesn't implement IFormattable-interface)
  • The NLog JsonSerializer could have an option to include serialization of Fields, and not just Properties. Also noticed that DefaultJsonSerializer is a public class, but it should have been internal one. Maybe change this for NLog 5. Instead there should be a Setup-method that allows one to update the NLog JsonSerializeOptions for the default NLog JsonSerializer.

Activity

  1. changed the title [-]JsonLayout MaxRecursionLimit = 0 should not call JsonSerializer[/-] [+] JsonSerializer could have an option to include serialization of Fields[/+] on Apr 27, 2020
  2. added 3 commits that reference this issue on Sep 5, 2026
    3a213df
    6de31bf
    cc54b6d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions