LogViewer: Adding support for viewing destructed properties #13357
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This simple PR addes support for "destructed properties" for the log viewer in the back office.
What is a destructed property?
Serilog stores properties associated with a log entry in different ways. Stringification is when Serilog will basically just call
.ToString()
on a parameter passed into the log method-call. Serilog also supports storing the property as a object, by Destructuring the object. This can be done in different ways but one simple way is to add a @ sign before the the name of the parameter inside the placeholder in the message template, like this:In this scenario, Serilog stores the variables as objects which makes them easier to look at in the logs. Some more info can be found here: https://github.com/serilog/serilog/wiki/Structured-Data. Using
Enrichers
we can also add more properties to the log entry that is not a part of the message template - hence before this PR it's impossible to see that data in the UI.Umbraco supports this all the way until the data is displayed in the backoffice log viewer UI, the line above will look like this
The data is passed from the backend controller to the view but before this PR the view did not know how to display it. With the fix in this PR the log entry details now looks like this.
Testing this PR