You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note when using Microsoft Extension Logging ILogger.BeginScope with NLog.Extension.Logging, then it will automatically update NLog ScopeContext with provided properties.
ScopeContext Nested States
Handles thread context naming of a scope. Ex. assigning MethodName for the method-call-scope:
Note when using Microsoft Extension Logging ILogger.BeginScope with NLog.Extension.Logging, then it will automatically update NLog ScopeContext with provided scope-name.
.NET Core logging
When using NLog.Extensions.Logging or NLog.Web.AspNetCore, you can also use BeginScope and more advanced options:
using(_logger.BeginScope(new[]{newKeyValuePair<string,object>("userid",request.UserId)})){_logger.LogDebug("Hello {World}","Earth");// Render userId via ${scopeproperty:userid} in target output}
NLog.Extensions.Logging v5.3.7 adds support for using ValueTuple for single scope-property (better performance):
using(_logger.BeginScope(("userid",request.UserId))){_logger.LogDebug("Hello {World}","Earth");// Render userId via ${scopeproperty:userid} in target output}