-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
NLog 4.3.8 onward writing logs to wrong folder with custom app domain #1828
Comments
Could you post your config? Especially of the fileTarget? |
Hi, I'd included it but had forgotten to enclose it in markup so it was hidden. I've fixed the post now, sorry about that! Thanks, Graham. |
Thx! |
summary: setting: changes 4.3.8: https://github.com/NLog/NLog/pulls?utf8=%E2%9C%93&q=%20is%3Aclosed%20milestone%3A4.3.8%20 |
Committed changes 4.3.7 -> 4.3.8: |
I expect that the issue is in filepathlayout Previous Dunno why the unit tests won't complain. @Tommyknocker1982 any idea if |
I think this goed wrong with only when app domains are created. @Tommyknocker1982 could you help us in writing an unit test? Probable we don't even have to write to a file in the unit test, but test this //create app domain, set basepath?
var layout = new FilePathLayout("logs\\app.log", true,FilePathKind.Unknown);
var filename = layout.Render(LogEventInfo.CreateNullEvent());
Assert.Equal(..., filename); Dunno how the app domain code would look like - I haven't much experience with it ;) |
Hi, Having looked at that change in 4.3.8, I think that most users would expect it to use the base directory of the current app domain by default. So instead of reverting the behaviour, would it be possible to add a new token ${processdir} which resolves to the directory of the parent process? This would let us have the old behaviour by specifying "${processdir}\logs\app.log" in our config, and is consistent with existing tokens like ${processinfo} etc... |
So something like this:
Maybe it could just be an option on the BaseDirLayoutRenderer, whether it should use AppDomain-BaseDir or CurrentProcess-BaseDir. |
Yes, that would work. Could that please be added to NLog 4.4? Thanks very much, Graham. |
yes But I really like to know, is this a bug? Is path.getfullname using the "processdir"? In which case is this not a problem?
Good idea! |
Hi, no I think that if anything a bug was present up to 4.3.7 and fixed in 4.3.8. I've managed to get the old behaviour back by writing a custom layout renderer, so we don't require any changes to NLog now. Thanks to everybody who helped investigate the issue, you've been brilliant! This issue can be marked as closed now. Cheers, Graham. |
@Tommyknocker1982 I still like to add this :) Do you have time to send a PR with this proposal? (including some tests)?
|
how could we test this in an unit test? |
Guess you could create a normal AppDomain (instead of a Medium-Trust-One) with a custom basedir, and see the file is written in the test-runner-bin-folder (Like where DoConcurrentTest is currently writing). |
thanks @snakefoot ! I will give it a try |
Type - Bug
NLog version - 4.3.8
Platform: - .Net 4.5
Current NLog config (xml or C#, if relevant)
Hi
We recently upgraded from NLog 4.3.3 to 4.3.11, and noticed that the logs for our application started to be written to the wrong folder. I narrowed it down to a change introduced in 4.3.8. The structure of our application is:
bootstrapper.exe is run first, with a working directory of AppFolder. It creates an app domain, into which it loads and runs Bin\app.exe. app.exe is configured to write logs to Logs\app.log. Up to and including NLog 4.3.7, it would correctly pick up the working directory of the bootstrapper.exe process and write logs fo AppFolder\Logs\app.log. But from NLog 4.3.8, it started writing logs to AppFolder\Bin\Logs\app.log. It seems that instead of using the working directory, it is using the location of the executable which is being loaded and run dynamically at runtime.
I couldn't find anything in the 4.3.8 release notes which suggests this change was intended, so if it is a bug, can it be fixed or reverted?
Thanks very much,
Graham Stoneman.
The text was updated successfully, but these errors were encountered: