-
Notifications
You must be signed in to change notification settings - Fork 360
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
NLog GoogleStackDriverTarget skip reflection on Stream-objects #5230
Conversation
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.
@chrisdunelm @jskeet If you can take a look, since you are more familiar with this code than I am.
@@ -141,11 +141,12 @@ protected override void InitializeTarget() | |||
jsonSettings.Converters.Add(new ToStringJsonConverter(typeof(MemberInfo))); | |||
jsonSettings.Converters.Add(new ToStringJsonConverter(typeof(Assembly))); | |||
jsonSettings.Converters.Add(new ToStringJsonConverter(typeof(Module))); | |||
jsonSettings.Converters.Add(new ToStringJsonConverter(typeof(System.IO.Stream))); |
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.
This is probably fine...
|
||
jsonSettings.Error = (sender, args) => | ||
{ | ||
// Serialization of properties that throws exceptions should not break everything | ||
InternalLogger.Warn(args.ErrorContext.Error, "GoogleStackdriver(Name={0}): Error serializing exception property: {1}", Name, args.ErrorContext.Member); | ||
InternalLogger.Debug(args.ErrorContext.Error, "GoogleStackdriver(Name={0}): Error serializing exception property: {1}", Name, args.ErrorContext.Member); |
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.
... but we might not want to change the level of logging serialization errors at this point.
Thanks @snakefoot for the PR. |
The NLog InternalLogger is for diagnostics
Warn / Error is for serious errors like invalid configuration, no access, no connection or something blew up. Thus the entire logging pipeline is broken.
NLog suppresses by default issues caused by bad input data being logged. Ex. invalid message template or missing parameters.
NLog users often wants to monitor these exceptional events. So configure the NLog InternalLogger to monitor for Warn/Error to see when the logging pipeline has broken.
Because users often uses giant frameworks, where they have no control of what is being logged then errors during reflection generates unwanted noise. Making it difficult to monitor the health of the NLog logging pipeline.
I introduced the logging the first place. Now I see the Loglevel was initially wrong. Please let me correct that mistake (Changing from Warn to Debug-level)
|
Thanks for the explanation of why the change is sensible. |
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.
LGTM
Changes in this release: - [Commit cbaa00a](googleapis@cbaa00a): Renormalize line endings - [Commit 02e2ddc](googleapis@02e2ddc): NLog GoogleStackDriverTarget skip reflection on Stream-objects ([issue 5230](googleapis#5230)) - [Commit 0e6d135](googleapis@0e6d135): NLog GoogleStackdriverTarget improve handling of System.Reflection (MemberInfo is better than MethodInfo)
Changes in this release: - [Commit cbaa00a](cbaa00a): Renormalize line endings - [Commit 02e2ddc](02e2ddc): NLog GoogleStackDriverTarget skip reflection on Stream-objects ([issue 5230](#5230)) - [Commit 0e6d135](0e6d135): NLog GoogleStackdriverTarget improve handling of System.Reflection (MemberInfo is better than MethodInfo)
Stream-objects properties often throw exceptions, and it is difficult to get useful information by reflection.