0

I have a Azure Function app (2.0) which depends on a .NET Standard Library contained within the same solution. I understand how to use the ILogger log within the azure function itself, but I want to use the same logger to log information within the .NET Standard library as well.

I want to avoid passing the log instance within the function to another class. I would prefer to use DI. How can I accomplish this?

For example, suppose I have a function app with a single function name FunctionName1. Suppose I have a dotnet standard 2.0 library named NetStandardLibrary1 with a class named MyClass1. Within the MyClass1, I have a single method named MyMethod1. I want to log information within MyMethod1 in the same way I would when I use ILogger log within FunctionName1.

Judy007
  • 5,484
  • 4
  • 46
  • 68

1 Answers1

0

You can set up Dependency Injection in Azure Functions. It's set up similarly to .net core a d you can use it to inject a logger.

See this post for details setting up DI.

https://ikethe.dev/azure-functions-adds-dependency-injection/