Question

I used Nlog for logging exceptions in my C# windows application and had a file called LogConfig.cs which has all the details about the location (path) and file name where to store these exceptions.

Now if I want to change the location where these files are getting logged I need to modify the code. Is there a way to change the location where the exceptions get logged without changing the code ?

I am trying to avoid a build into production just for changing the path where locations are getting saved.

Is storing this info (path and file name) in a separate text file and reading from it the best way to do it. That way I can just modify the text file in production and there would be no need for a code change.

Was it helpful?

Solution

You can put all your logging configuration, including paths, to NLog.config , and place it in the same folder as your exe file. It will be loaded automatically and applied by NLog.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top