Closed Ozzard closed 4 years ago
@Ozzard can I ask you to pick up this one please?
When using Single File Publish, then NLog will fail to load the NLog.config placed next to the single-executable. NLog will always prioritize the NLog.config in the BaseDirectory, and BaseDirectory is special for single-file-publish (On windows it is a "secret" temp-directory where the app has been unzipped, so a broken illusion). The directory order used to find NLog.config will be changed with NLog 5.0, but that is far out in the future.
There are two work-arounds:
Instead of using NLog.config, then use SingleApp.exe.nlog. NLog 4.6.8 will prioritize the SingleApp.exe.nlog in the process-directory over any default SingleApp.exe.nlog found in BaseDirectory (Must also rename the NLog.config packaged into the SingleApp.exe as SingleApp.exe.nlog)
Change the application to manually check existence of NLog.config file in the process-directory, and load this manually when it exists.
@snakefoot For whatever reason, I couldn't get this behaviour to work on Linux. CentOS 7, the Linux SwaMe single executable from the single-exe build on the production-logging branch (updated to NLog 4.7.0 in all projects that use it), unzip, chmod +x SwaMe.Console, and add a valid SwaMe.Console.nlog file in the same directory. Can you see anything obviously wrong with that series of steps?
Like I wrote before. The first trick suggested, requires that one doesn't have any files named NLog.config. The config file must be named SingleApp.exe.nlog (the one packaged into and the one placed next to override). To repeat no files named NLog.config files at all. And you must use NLog 4.6.8 or newer.
Again directory search order will change with NLog 5, but it is a breaking change. Sadly enough the single file publish (with the broken BaseDirectory illusion) was released faster than NLog project could handle.
For various reasons including this one, we've moved away from a single executable for the command-line version. Closing as WONTFIX.
To configure production logging, I wanted to change the NLog options via NLog.Config. The all-in-one executable appears not to read a NLog.config placed in the same directory.