Skip to content
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

Log4JXmlEventLayout - Fixed bug with empty nlog:properties. Log4JXmlEventLayoutRenderer : added IncludeAllProperties option. Log4JXmlEventLayout: added IncludeAllProperties, IncludeMdlc and IncludeMdc option #2090

Merged

Conversation

snakefoot
Copy link
Contributor

@snakefoot snakefoot commented May 3, 2017

Fixes #2088

  • Log4JXmlEventLayout - Fixed bug with empty nlog:properties.
  • Log4JXmlEventLayout: added IncludeAllProperties, IncludeMdlc and IncludeMdc option
  • Log4JXmlEventLayoutRenderer : added IncludeAllProperties option.

@snakefoot snakefoot force-pushed the Log4JXmlEventLayoutNLogProperties branch 2 times, most recently from bcf200b to 99b2137 Compare May 3, 2017 20:11
@codecov
Copy link

codecov bot commented May 3, 2017

Codecov Report

Merging #2090 into master will decrease coverage by <1%.
The diff coverage is 69%.

@@           Coverage Diff           @@
##           master   #2090    +/-   ##
=======================================
- Coverage      81%     81%   -<1%     
=======================================
  Files         289     289            
  Lines       19924   19946    +22     
  Branches     2356    2360     +4     
=======================================
+ Hits        16210   16217     +7     
- Misses       3115    3124     +9     
- Partials      599     605     +6

@snakefoot snakefoot force-pushed the Log4JXmlEventLayoutNLogProperties branch 4 times, most recently from 39d9dc2 to 15ec055 Compare May 3, 2017 21:48
@304NotModified 304NotModified added the bug Bug report / Bug fix label May 3, 2017
@304NotModified 304NotModified added this to the 4.4.9 milestone May 3, 2017
@304NotModified
Copy link
Member

changes without newlines:

https://github.com/NLog/NLog/pull/2090/files?w=1

Copy link
Member

@304NotModified 304NotModified left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

/// Gets or sets a value indicating whether to include contents of the <see cref="MappedDiagnosticsContext"/> dictionary.
/// </summary>
/// <docgen category='Payload Options' order='10' />
public bool IncludeMdc { get { return Renderer.IncludeMdc; } set { Renderer.IncludeMdc = value; } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should add an interface that dictates the properties shared by Log4JXmlEventLayout.cs and Log4JXmlEventLayoutRenderer.cs ?

Then it's more clear those are coupled. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. Just thought it was weird that the Layout didn't have access to all the fancy options on the layout-renderer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, added for the feature #2091

continue;

xtw.WriteStartElement("log4j", "data", dummyNamespace);
xtw.WriteAttributeSafeString("name", propertyKey);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the feature we should unduplicate this cdeo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the duplicate code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

@@ -329,6 +332,28 @@ protected override void Append(StringBuilder builder, LogEventInfo logEvent)
}
#endif

if (this.IncludeAllProperties)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this a new feature, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

private static IDictionary<string, object> ThreadDictionary
private static readonly IDictionary<string, object> EmptyDefaultDictionary = new SortHelpers.ReadOnlySingleBucketDictionary<string, object>();

private static IDictionary<string, object> GetThreadDictionary(bool create = true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please document when we should set create to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated XML-documentation

@304NotModified 304NotModified changed the title Log4JXmlEventLayout - Fixed bug with empty nlog:properties Log4JXmlEventLayout - Fixed bug with empty nlog:properties & added IncludeAllProperties option May 3, 2017
@snakefoot snakefoot force-pushed the Log4JXmlEventLayoutNLogProperties branch from 15ec055 to 2cf9922 Compare May 3, 2017 22:08
@snakefoot snakefoot force-pushed the Log4JXmlEventLayoutNLogProperties branch from 2cf9922 to 2f5e3cc Compare May 3, 2017 22:13
@@ -156,6 +156,10 @@ public void Log4JXmlTest()
break;
#endif

case "nlogPropertyKey":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@snakefoot snakefoot May 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand. It is now also part of the standard log4j-properties because of IncludeAllProperties=true. The non-standard nlog-properties can only be handled by custom parsers. Not my idea to initially place the LogEvent-properties in a nlog-xml-tag not recognized by the log4j-standard.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK thanks

@304NotModified 304NotModified merged commit ff687c7 into NLog:master May 4, 2017
@304NotModified
Copy link
Member

Could you please update the docs? Thanks!

@304NotModified 304NotModified changed the title Log4JXmlEventLayout - Fixed bug with empty nlog:properties & added IncludeAllProperties option Log4JXmlEventLayout - Fixed bug with empty nlog:properties. Log4JXmlEventLayout : added IncludeAllProperties, option. Log4JXmlEventLayoutRenderer: added IncludeAllProperties, IncludeMdlc and IncludeMdc option May 4, 2017
@304NotModified 304NotModified changed the title Log4JXmlEventLayout - Fixed bug with empty nlog:properties. Log4JXmlEventLayout : added IncludeAllProperties, option. Log4JXmlEventLayoutRenderer: added IncludeAllProperties, IncludeMdlc and IncludeMdc option Log4JXmlEventLayout - Fixed bug with empty nlog:properties. Log4JXmlEventLayoutRenderer : added IncludeAllProperties, option. Log4JXmlEventLayout: added IncludeAllProperties, IncludeMdlc and IncludeMdc option May 4, 2017
@304NotModified 304NotModified changed the title Log4JXmlEventLayout - Fixed bug with empty nlog:properties. Log4JXmlEventLayoutRenderer : added IncludeAllProperties, option. Log4JXmlEventLayout: added IncludeAllProperties, IncludeMdlc and IncludeMdc option Log4JXmlEventLayout - Fixed bug with empty nlog:properties. Log4JXmlEventLayoutRenderer : added IncludeAllProperties option. Log4JXmlEventLayout: added IncludeAllProperties, IncludeMdlc and IncludeMdc option May 4, 2017
@snakefoot
Copy link
Contributor Author

@snakefoot snakefoot deleted the Log4JXmlEventLayoutNLogProperties branch October 10, 2017 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report / Bug fix feature log4jxml-layout Log4j XML Layout
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants