I am using Microsoft.Extensions.Logging together with NLog. My app is .NET Core 3.1.
I would like to extend logging with custom fields.
Is it possible or will I need to use NLog directly?
<parameter name="@custom_guid" layout="${custom_guid}"/>
var config = new Dictionary<string, object>();
config.Add("custom_guid", "test");
_logger.LogInformation("Test message", config);
You could do this:
var config = new Dictionary<string, object>();
config.Add("custom_guid", "test");
using (_logger.BeginScope(config))
{
_logger.LogInformation("Test message");
}
And use ${mdlc:custom_guid}