Skip to content

Commit

Permalink
Merge pull request #334 from erwinwolff/master
Browse files Browse the repository at this point in the history
Fixes empty "properties" collection.
  • Loading branch information
kichristensen committed May 1, 2014
2 parents d21cc1f + acb1636 commit 545029e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/NLog/Targets/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ protected virtual void Write(LogEventInfo logEvent)
protected virtual void Write(AsyncLogEventInfo logEvent)
{
try
{
{
this.MergeEventProperties(logEvent.LogEvent);

this.Write(logEvent.LogEvent);
logEvent.Continuation(null);
}
Expand Down Expand Up @@ -472,6 +474,22 @@ private void GetAllLayouts()
{
this.allLayouts = new List<Layout>(ObjectGraphScanner.FindReachableObjects<Layout>(this));
InternalLogger.Trace("{0} has {1} layouts", this, this.allLayouts.Count);
}

private void MergeEventProperties(LogEventInfo logEvent)
{
foreach (var item in logEvent.Parameters)
{
if (item.GetType() == typeof(LogEventInfo))
{

foreach (var propertyItem in ((LogEventInfo)item).Properties)
{
logEvent.Properties.Remove(propertyItem.Key);
logEvent.Properties.Add(propertyItem);
}
}
}
}
}
}

0 comments on commit 545029e

Please sign in to comment.