0

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);
Julian
  • 33,915
  • 22
  • 119
  • 174
cashmere
  • 885
  • 3
  • 12
  • 37

1 Answers1

0

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}

Julian
  • 33,915
  • 22
  • 119
  • 174