I have these projects in my solution:
- .Net Core 3.1 Worker Service
- .Net Core 3.1 Class library - for configure the log4net
But my log4net.config file is inside my worker service project. When I'm debugging, it is logging to the file which is configured in the log4net.config.
But when I install the Worker Service as a Windows service, it doesn't log to the file.
And when I checked the log4net.config location it has these values:
- When debugging:
D:\myrepos\webapicore\Development\Message.Consumer\log4net.config - When running as a service:
C:\WINDOWS\system32\log4net.config
So I believe, since the log4net.config is not available in C:\WINDOWS\system32\ it cannot do the logging.
UPDATE: I'm using following code to retrieve the log4net.config
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
Any idea to solve this?
Thanks.