We are replacing in our project the log4net
to Serilog
. In many of our classes we are using the method LogManager.GetLogger
of log4net when giving as a parameter the class name using MethodBase.GetCurrentMethod().DeclaringType
, so we could know in which class the log was written.
Is there any method which is equivalent in Serilog which can give me the logger? I know that there is the option of ForContext()
which you can specify the class you're in, but I still don't know how to get an instance of a logger without some kind of logManager.
P.S
To give a logger as a parameter to each class constructor (instead of using Getlogger()
) would take some time and I would really prefer to avoid this option.
After I did some research, I founded out that there is NO Log4Net
GetLogger() equivalent in Serilog.