diff --git a/BetterStack.Logs.NLog/BetterStackLogsTarget.cs b/BetterStack.Logs.NLog/BetterStackLogsTarget.cs
index 723c309..45ae033 100644
--- a/BetterStack.Logs.NLog/BetterStackLogsTarget.cs
+++ b/BetterStack.Logs.NLog/BetterStackLogsTarget.cs
@@ -56,6 +56,11 @@ public bool CaptureSourceLocation
///
public bool IncludeGlobalDiagnosticContext { get; set; } = true;
+ ///
+ /// Include Include ScopeContext's properties in logs.
+ ///
+ public bool IncludeScopeContext { get; set; } = false;
+
///
/// Control callsite capture of source-file and source-linenumber.
///
@@ -147,6 +152,20 @@ protected override void Write(LogEventInfo logEvent)
contextDictionary["gdc"] = gdcDict;
}
}
+
+ if (IncludeScopeContext)
+ {
+ Dictionary scopedProperties = null;
+ foreach (var prop in ScopeContext.GetAllProperties())
+ {
+ if (scopedProperties == null)
+ scopedProperties = new Dictionary();
+ scopedProperties[prop.Key] = prop.Value;
+ }
+ if (scopedProperties != null)
+ contextDictionary["sc"] = scopedProperties;
+ }
+
string logMessage = RenderLogEvent(this.Layout, logEvent);
var log = new Log {