-
Notifications
You must be signed in to change notification settings - Fork 151
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
Fix docs ${configsetting} -> NLog.Extensions.Configuration #250
Comments
@snakefoot do you think we could reference NLog.Extensions.Configuration from nlog.web.aspnetcore? If as bit difficult to see if they both share the same dependencies. I'm afraid not |
The closest thing is:
I'm not using |
Also curious if the dependencies for NLog.Extensions.Configuration are correct. Maybe it should be split into 4 packages (abstract + json + xml + ini). Since the abstract-package will be enough for Since users of Ex. Serilog.Settings.Configuration only depends on |
one package with minimal dependencies for asp.net core would be great! |
Hey there! First of all: Thanks a lot for your great work on NLog! Very much appreciated! I am currently struggling trying to make the configsetting LayoutRenderer work in my dotnet core application. I basically followed the tutorial on https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2. Logging to files and a database works great, but I keep getting the following error when trying to log a key from my appsettings.json: Error parsing layout configsetting will be ignored. Exception: System.ArgumentException: LayoutRenderer cannot be found: 'configsetting' As far as I understood from the docs this LayoutRenderer should be included in NLog.Web.AspNetCore 4.7, but I also tried adding NLog.Extensions.Logging and NLog.Extensions.Configuration to my project. Nothing helped. Sorry if this should be the wrong place for my question, but this issue seemed related even though I did not fully comprehend it :) |
@jpett You are not the wrong place. Sadly enough I think my first attempt to improve support for appsettings.json wasn't complete. It pretty much was a copy of https://www.nuget.org/packages/NLog.Appsettings.Standard/ But I don't like that it actually performs its own explicit loading of the appsettings.json-file. Instead I would much rather prefer that it uses the config that already had been loaded by the hosting-environment. This is why I have now created PR #248 When/if this PR has been approved then I will change NLog.Web.AspNetCore to depend on NLog.Extension.Configuration instead of NLog.Extension.Logging. Then further down the road I will add support for having the nlog.config in the appsettings.json. While waiting for all this work to be reviewed and approved, then I think you are better off using https://www.nuget.org/packages/NLog.Appsettings.Standard/ |
@snakefoot Thanks a lot for your quick reply! NLog.Appsettings.Standard worked for me indeed :) |
@snakefoot Is the information in your comment still up to date? |
@Giorgi PR #248 is still awaiting review (along with NLog 4.6). While waiting for the train then NLog.Appsettings.Standard should still work. |
Thanks, it worked. |
@snakefoot it's not working when deployed to server (asp.net core hosted in iis using full framework). Any ideas ? |
Not sure what is not working. But as usual it is a good idea to check NLog InternalLogger. Maybe verify if extension dlls are loaded properply.
|
I use it to set connection string for database target. In the internal log file I get I think the assembly gets loaded because I see this in internal log: Info Loading assembly: NLog.Appsettings.Standard I don't see any difference in internal log file. |
Since it is working locally then I guess you have to find out why it fails to load your AppSettings.json
Maybe make a PR for the extension dll so it will write to NLog Internal Logger where it loads the json file from.
This is the reason I'm trying to fix ${configsetting} to not load any files, but use the already loaded config from the host-environment. But my PR is still pending review.
|
Yes, I found the reason. It was trying to load a different settings.json file because |
@304NotModified When NLog.Extension.Logging ver. 1.4.0 is released, then the world is back again to normal. Then just need to revert this pull-request: And update this wiki-page: https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer |
@304NotModified Have now updated the Wiki: https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer |
@304NotModified Guess it can be resolved with milestone |
Thanks for the update! |
Fix:
The text was updated successfully, but these errors were encountered: