Skip to content

Is there a way to tell RenderedCompactJsonFormatter or to not render some placeholders? #68

@james-hu

Description

@james-hu

I have this use case:

  • There are multiple variables I want to included in logging
  • For most of them, they are strings or numbers, so that I am happy for them to be rendered in the message
  • Some of them are huge objects, so that I want it to be not rendered in the message, but still attached as a destructured property of the output

This is the example code with "$" showing the use case:

_logger.LogDebug("Created a Job {jobId} for {customer}. Details: {$job}", jobId, customerName, jobDetails);

For CompactJsonFormatter and RenderedCompactJsonFormatter, the output does not contain destructured details of jobDetails in the property "job". So that it is not very useful to me.

This is the example code with "@" showing the use case:

_logger.LogDebug("Created a Job {jobId} for {customer}. Details: {@jobDetails}", jobId, customerName, jobDetails);

For both CompactJsonFormatter and RenderedCompactJsonFormatter, the output contains destructured details of jobDetails in the property "job".
For RenderedCompactJsonFormatter, the rendered message contains fully destructured details of jobDetails too, so that the same information gets duplicated. Is there a way to tell RenderedCompactJsonFormatter not to render it in the message?

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