I have a couple of applications that I am working on. Both of them utilize NLog. Both of them have an event source registered on my computer. When I start one of them it works, and writes things to the windows event log. No problems. When I start the other app NLog apparently decides it doesn't want to write to the event log, and it rewrites the NLog.config file to write to a default file with default settings instead. That is maybe ok on my computer, but there is no way I want that to ever happen in a production environment. How can I prevent the file from getting rewritten?
As a side note, both of these applications are services as well. If I run the problematic one as a service instead of in the console, then everything works well. The other app works correctly whether it is running as a service or not. The NLog.config files for both apps are identical, except for the event log source. Any idea what could cause this?
I finally figured out what was happening. It has nothing to do with NLog. I have a few executables in the same solution, pointed to the same output folder. I added NLog.config files to all of them. Somehow it never occurred to me that these would all end up in the same folder and be conflicting with each other.
When I built normally it ended up pulling the NLog.config for my main project, but when debugging through VS2010, it ended up using one of the other NLog.config files for some reason. Thus the strange issue where the NLog.config file would be "overwritten" based on how I start the program.
The solution is obviously to remove the redundant NLog.config files from the secondary executables and stick with just one.