I have a .Net network application that I am trying to add to the log via NLog. In previous projects, I just used something like the following at the beginning of each class:
private static Logger logger = LogManager.GetCurrentClassLogger();
I try, if possible, to follow the best recommendations with this project.
My question is: how can I insert a registrar that has the full name of the class into which it is inserted?
In my startup.cs file so far I have the following:
services.AddScoped<BLL.Logging.NLogLogger>();
Currently, the class NLogLoggercreates an instance of NLog Logger through GetCurrentClassLogger(), which when used will only report the name as "BLL.Logging.NLogLogger", and not the actual class that is the logger injected into.
To simplify the question and make it more universal: How can you pass the class name that .Net Core is going to introduce the class into?
I thought of something like below, but not sure how to achieve it:
services.AddScoped<BLL.Logging.NLogLogger>(serviceProvider => new BLL.Logging.NLogLogger("class name here"));
source
share