简体   繁体   中英

c# window service not picking up log4net settings after installing from custom installer

I have a client application which is an window server with its dlls, exe and config file.

I have created a custom installer for it which will copy this in program files and update its config.

This is the code which I am using

//read config and update
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)+"\\EventLogTracer.exe"; //this is app.exe path not app.exe.config path
Configuration evetconfig =ConfigurationManager.OpenExeConfiguration(path);
evetconfig.AppSettings.Settings.Remove("baseUri");
 evetconfig.AppSettings.Settings.Add("baseUri", "https://192.168.1.79:443/rest");
evetconfig.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");

I have log4net configuration also in my app.exe.config file. Which I am not touching at all. My installer also have same log4net settings.

Now I created its MSI file and perform a run of different machine by installing it.

Now on my local machine its getting installed perfect and its picking all settings and log4net settings. All works perfect.

On my VM machine I tried installing it. It got installed and posting data to server. But its not picking up log4net settings and not writting any logs at all.

Whats the issue here, I am no brainer. Can anybody help?

Thanks

I had a similar issue with a WCF application deployed on IIS, and it turned out to be a permissions related issue. I know you're not using IIS, but your issue also sounds permissions related.

What OS is being used in production? Server 2008? If so, didn't they lock down permissions on Program Files a bit more than in previous Windows versions? Try giving full control on the folder where the log is written to all users and see if that works. If it does, you know it's a permissions issue and you can then figure out what specific permissions you need to set for which users (as opposed to leaving it at full control for all users).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM