unable to get log4net working with .net windows service

Please note that when the process is run as Windows Service, Environment.CurrentDirectory will be “C:\Windows\system32”

So if you put the log4net configuration file (log4net.config) next to your *.exe, you can use the following code to configure log4net.

var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
XmlConfigurator.Configure(new FileInfo(Path.Combine(assemblyFolder, "log4net.config")));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)