2

I created a .Net standard library and I moved the entire Serilog configuration to that library. Now I just referenced class library in API project without adding Serilog packages to API.

Problem: ILogger inside the controller is not logging a message but the message in Program.cs works fine. I understand why it is working in the Program.cs because I am using Serlog's Log.Logger.information() to write a message but the controller is not logging means the dependency injection for ILogger is somewhere broken.

Note: if I eliminate the class library and write the same initialization code in the program.cs and add all Serilog packages in the API project then everything works fine.

I created a sample project and published in Github. API projects can be started and should see a message in console output. https://github.com/giridharprakash/QuicLog

Thanks in advance.

0 Answers0