Skip to content
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

Closed
7 tasks
304NotModified opened this issue Sep 25, 2018 · 19 comments
Closed
7 tasks

Fix docs ${configsetting} -> NLog.Extensions.Configuration #250

304NotModified opened this issue Sep 25, 2018 · 19 comments
Labels
Milestone

Comments

@304NotModified
Copy link
Member

304NotModified commented Sep 25, 2018

Fix:

@304NotModified Maybe a little confusing:

  • Added ${configsetting} for appsettings.json and others (@snakefoot)

Since ${configsetting} is not part of NLog.Extensions.Logging but part of:

https://www.nuget.org/packages/NLog.Extensions.Configuration/
--

@304NotModified 304NotModified changed the title Fix docs NL Fix docs ${configsetting} -> NLog.Extensions.Configuration Sep 25, 2018
@304NotModified 304NotModified added this to the 1.3 milestone Sep 25, 2018
@304NotModified
Copy link
Member Author

304NotModified commented Sep 25, 2018

@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

@snakefoot
Copy link
Contributor

The closest thing is:

  • Microsoft.Extensions.Configuration.Abstractions

I'm not using nlog.web.aspnetcore so probably not the right one to ask. But I think it should have a dependency on NLog.Extensions.Configuration. Especially when NLog 4.6-BETA is out and NLog.Extensions.Configuration allows one to load NLog-configuration from appsettings.json.

@snakefoot
Copy link
Contributor

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 nlog.web.aspnetcore (Just need an extension method to setup DefaultConfiguration on ConfigSetting-LayoutRenderer).

Since users of nlog.web.aspnetcore already have loaded the app-configuration, and most likely not planning to load any config from an external-file.

Ex. Serilog.Settings.Configuration only depends on Microsoft.Extensions.Configuration.Abstractions.

@304NotModified
Copy link
Member Author

304NotModified commented Sep 26, 2018

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 nlog.web.aspnetcore (Just need an extension method to setup DefaultConfiguration on ConfigSetting-LayoutRenderer).

one package with minimal dependencies for asp.net core would be great!

@jpett
Copy link

jpett commented Oct 4, 2018

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'
at NLog.Config.Factory`2.CreateInstance(String name)
at NLog.Layouts.LayoutParser.GetLayoutRenderer(ConfigurationItemFactory configurationItemFactory, String name)

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 :)

@snakefoot
Copy link
Contributor

snakefoot commented Oct 4, 2018

@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/

@jpett
Copy link

jpett commented Oct 5, 2018

@snakefoot Thanks a lot for your quick reply! NLog.Appsettings.Standard worked for me indeed :)

@Giorgi
Copy link

Giorgi commented Jan 3, 2019

@snakefoot Is the information in your comment still up to date?

@snakefoot
Copy link
Contributor

@Giorgi PR #248 is still awaiting review (along with NLog 4.6). While waiting for the train then NLog.Appsettings.Standard should still work.

@Giorgi
Copy link

Giorgi commented Jan 4, 2019

Thanks, it worked.

@Giorgi
Copy link

Giorgi commented Jan 8, 2019

@snakefoot it's not working when deployed to server (asp.net core hosted in iis using full framework). Any ideas ?

@snakefoot
Copy link
Contributor

snakefoot commented Jan 8, 2019 via email

@Giorgi
Copy link

Giorgi commented Jan 8, 2019

I use it to set connection string for database target. In the internal log file I get
Exception: System.InvalidOperationException: OracleConnection.ConnectionString is invalid

I think the assembly gets loaded because I see this in internal log:

Info Loading assembly: NLog.Appsettings.Standard
Debug ScanAssembly('NLog.Appsettings.Standard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null')

I don't see any difference in internal log file.

@snakefoot
Copy link
Contributor

snakefoot commented Jan 8, 2019 via email

@Giorgi
Copy link

Giorgi commented Jan 8, 2019

Yes, I found the reason. It was trying to load a different settings.json file because Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") returns an empty string while env.EnvironmentName returns Production

@snakefoot
Copy link
Contributor

snakefoot commented Jan 13, 2019

@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:

NLog/NLog.github.io#78

And update this wiki-page:

https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer

@snakefoot
Copy link
Contributor

@304NotModified Have now updated the Wiki: https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer

@snakefoot
Copy link
Contributor

@304NotModified Guess it can be resolved with milestone ver. 1.4 of NLog.Extension.Logging.

@304NotModified 304NotModified modified the milestones: 1.3, 1.4 Feb 1, 2019
@304NotModified
Copy link
Member Author

Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants