I have some trouble by configuring the loggers in my ASP.Net Core server application to create different log files for some projects.
Solution:
+ MyProject.Core (Library)
+ MyProject.DeviceApi.Controller (Library)
+ MyProject.WebsiteApi.Controler (Library)
+ MyProject.Server (ASP.NET Core)
MyProject.Server
depends on MyProject.DeviceApi.Controller
and MyProject.WebsiteApi.Controller
.
MyProject.DeviceApi.Controller
depends on MyProject.Core
.
MyProject.WebsiteApi.Controller
depends on MyProject.Core
.
Services in MyProject.Core
using loggers as interface.
Services containing logging statements don't have to be registrered as singeltons
The MyProject.Server
project registers controllers, items for di and defines some background task (like scheduled jobs).
There are two separate controller projects because they are independend, each contains many controllers and they should be logical devided.
What I want
- Server.log (Contains entries triggered by Operations directly in
MyProject.Server
) - DeviceApi.log (Contains entries triggered by operations directly in
MyProject.DeviceApi.Controller
) - WebsiteApi.log (Contains entries triggered by operations directly in
MyProject.WebsiteApi.Controller
)
Currently I have no custom configuration, because all atemps failed to get the desired result.
I'm also fine using a logging dependncy like nlog.
But as far as I know I have to create separate instances for each service in MyProject.Core
using a different logger instance.