-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonLayout: add includeAllProperties & excludeProperties #1754
JsonLayout: add includeAllProperties & excludeProperties #1754
Conversation
Current coverage is 80% (diff: 100%)@@ master #1754 diff @@
==========================================
Files 274 274
Lines 17422 17472 +50
Methods 2741 2743 +2
Messages 0 0
Branches 1966 1981 +15
==========================================
+ Hits 13974 14024 +50
Misses 3005 3005
Partials 443 443
|
/// <summary> | ||
/// List of property names to exclude when IncludeAllProperties is true | ||
/// </summary> | ||
public IList<string> ExcludedProperties { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}); | ||
} | ||
else if ( | ||
prop.Value is bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should integrate this with #1740 (injecting Json serializer) . What do you think?
We try to use
preferred to use the JsonSerializer of #1740? update: we have to be careful to be backwardscompatibe.
Also #1740? |
Intent to release this nice feature into 4.4 :) |
We need to do the docs in wiki right? |
docs done: |
needs to update xsd schema now, cause |
thanks @AuthorProxy , created a new issue for it: #2037 |
@AuthorProxy It seems that nlog.schema was up-to-date, but not the one on nlog-project.org. This has been fixed. Have to find out how to do this automatically. (powershell script or something like that) |
Here's an initial attempt at adding "AllEventProperties" functionality to
JsonLayout
as mentioned in issue #1686. This is the first time I've made a pull request on GitHub. So if I'm not following the proper procedure or conventions let me know.I have few questions:
I'm using a
for each
loop to iterate over the the log event properties, but everywhere else it looks like there's been an effort to use afor
loop to avoid allocating an Enumerator. There doesn't look like a way to access the items or keys in a dictionary by index though. Is there some other way I could optimize this?LogEventInfo.Properties
is anIDictionary<object,object>
. How should the keys be converted into a string property names? Should I just useToString()
as I have now? When would the key of a property not be a string?Any ideas on how to handle property values that are collections or objects? I'm guessing we wouldn't want to use reflection to read properties from object values due to the performance hit. However, for my use case I'd like it to be able to identify collection properties and have them returned as an array of values in the JSON rather then "System.Collections.Generic.List`1[System.String]".
This change is