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
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?
The text was updated successfully, but these errors were encountered:
Yes, this should work, I didn't think of this approach ☺️ Thanks!
Based on this approach, I think an extension can be created as a sugar for making the code easier to write.
I have this use case:
This is the example code with "$" showing the use case:
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:
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?
The text was updated successfully, but these errors were encountered: