Given a File->New->Azure Functions v2 App, I'm trying to get a reference to either an ILoggerFactory
or an ILogger<T>
.
I'm doing this in the StartUp.cs
class which is ran on the function app start.
Given the following code a weird exception is thrown:
var serviceProvider = builder.Services.BuildServiceProvider();
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
with the following exception:
A host error has occurred
[27/02/2019 8:21:22 AM] Microsoft.Extensions.DependencyInjection: Unable to resolve service for type 'Microsoft.Azure.WebJobs.Script.IFileLoggingStatusManager' while attempting to activate 'Microsoft.Azure.WebJobs.Script.Diagnostics.HostFileLoggerProvider'.
Value cannot be null.
Parameter name: provider
What is going on?
The full test repo/code can be found here on GitHub.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…