NLog + Azure Functions 3.1
Azure function Startup class
public override void Configure(IFunctionsHostBuilder builder)
{
var logger = LogManager.Setup()
.SetupExtensions(e => e.AutoLoadAssemblies(false))
.LoadConfigurationFromFile(currentDirectory + Path.DirectorySeparatorChar + 'NLog.config')
.GetLogger(configuration.GetSection('logging:nlog:defaultloggername')?.Value);
builder.Services.AddLogging((logger) =>
{
//logger.ClearProviders();
logger.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
logger.AddNLog();
}).BuildServiceProvider();
}
//NLog.config
<variable name='commonLayout' value='${longdate}|${logger}|${uppercase:${level}}|${message}, ${all-event-properties:format=[key]=[value]:separator=, } ${exception}' />
Azure Function
public FunctionA(ILogger<FunctionA> logger){}
Structured logging does not work with Azure function 3.1. The loggername is spitting out FunctionA, how can I change this to use NLog object in the Azure function. Note: I'm using Azure Function 3.1, I can inject NLog in .net core 2.1 though.