-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use application base directory to locate self diagnostic config file #1865
Use application base directory to locate self diagnostic config file #1865
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1865 +/- ##
==========================================
+ Coverage 83.77% 84.00% +0.22%
==========================================
Files 187 187
Lines 5967 5988 +21
==========================================
+ Hits 4999 5030 +31
+ Misses 968 958 -10
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be an option but not the only option.
In many environments the application does not have write permission to its base directory.
Please consider this:
- User the "current working directory".
- If there is no configuration file in the "current working directory", use the application image base directory.
It's not the app which is supposed to write on its base directory, but the user who wants to enable diagnostics. This change only change the location scanned for the self diagnostic config file. It's expected that you (deployment, admin, etc.) can write config files on the app directory. Of course, the config itself should point to a directory where the app can write logs. Currently, the location scanned is the current directory, which in most (all ?) cases the base directory. Most .NET apps are considering that config files are located along the binaries. Even for asp.net core apps. Only in IIS, the w3wp process is setting It could be interesting to check how asp.net core itself determines where the web.config is located. (or appsettings.json for asp.net core). I think adopting a similar logic would be sufficent (instead of learning about a new location convention). |
I thought I mentioned "configuration file" in comment 😄 |
Sorry, I edited my reply just now because your comment was clear, and I misunderstood it. You have a good point about frozen deployments. I will update the code based on your suggestion. |
…ck to app base directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (need to wait for the CLA though).
Please update the CHANGELOG.
Done, I was able to sign the CLA
|
I have tested the effets of my PR using It means that the readme changes could also be simplified to say that in most cases, you could just drop the file along your application. And in the case where the base directory is not writable, you can use the directory returned by Environment.GetCurrentDirectory() if different. |
done |
Fixes #1714. Invalidate #1717
Changes
This change updates the way the self diagnostic config file is located. Instead of using environment current directory, it uses the application base directory.
This fixes self diagnostic config file lookup in ASP.NET applications and makes the app compatible with all kinds of hosting.
This PR should also update documentation (readme).