Closed sandycs-protoss closed 1 year ago
Based on your code sample, you register the file logger provider in your controllers into separate DI containers than the ASP.NET Core controller. Instead of this, you need to register the logger provider only once in your Program.cs.
Please refer to the ASP.NET Core 6+ application (minimal hosting model) section of the configuration guide for .NET 5+.
I'm running a WEBAPI in ASP.NET CORE 7.0 however I need to code them again in every controller. The logging service provide by ASP.NET Core can be setting in program.cs and nothing is need to be done in the controller.
public apiController(ILogger logger)
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
The apicontroller is one of the controller. In the logging service provice by ASP.NET Core, I just need to use the logger in the parameter. Am I do anything wrong?