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

.NET Core 3.0 with IHostEnvironment #350

Closed
jasonycw opened this issue Mar 11, 2019 · 17 comments
Closed

.NET Core 3.0 with IHostEnvironment #350

jasonycw opened this issue Mar 11, 2019 · 17 comments

Comments

@jasonycw
Copy link

In .NET Core 2.X we can use IHostingEnvironment to .ConfigureNLog(...) which NLog.config file to be used.
But with .NET Core 3.0, IHostingEnvironment will become obsoleted and will become be replaced by IHostEnvironment eventually according to dotnet/aspnetcore#7749
https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-2.2&tabs=visual-studio#hostbuilder-replaces-webhostbuilder

Any planing on when will NLog support .NET Core 3.0 ?

@304NotModified
Copy link
Member

304NotModified commented Mar 11, 2019

Thanks for the heads up!

Could you please help us with a PR?

@snakefoot
Copy link
Contributor

snakefoot commented Mar 11, 2019

@jasonycw Just curious. Which version of NetStandard supports this new IHostEnvironment ?

@304NotModified
Copy link
Member

Good question, I think 2.1: https://github.com/dotnet/standard/blob/master/docs/versions.md

@snakefoot
Copy link
Contributor

snakefoot commented Mar 11, 2019

So NetStandard2.1 with dependency on 3.0.0 preview-package: https://www.nuget.org/packages/Microsoft.Extensions.Hosting.Abstractions/ ?

When a single platform depends on a preview-package, then the entire package also becomes a preview-package. Not sure we are going to have NLog.Extension.Logging in preview-stage until NetCore3 is fully ready. Or am I missing something?

@304NotModified
Copy link
Member

Yes, I think it makes sense to merge of .net core issue final, or maybe indeed a preview package (but not from master then).

@snakefoot
Copy link
Contributor

snakefoot commented Mar 11, 2019

Yes master (or dev) would not be a good place for preview-features. Since we like to make changes and releases while waiting for NetCore3 to complete.

But then the door to merge-hell suddenly opens up. And explaining why feature in one branch is not in latest netcore3-branch-preview-release (Happy memories from Nlog 5 forever branch).

@304NotModified 304NotModified transferred this issue from NLog/NLog Mar 11, 2019
@304NotModified
Copy link
Member

But then the door to merge-hell suddenly opens up. And explaining why feature in one branch is not in latest netcore3-branch-preview-release (Happy memories from Nlog 5 forever branch).

True, confusing, but it did work ;)

Anyway, a PR and a PR package (from AppVeyor) sounds the best for me.

@snakefoot
Copy link
Contributor

@jasonycw When looking at the NetCore3 sample code from your link, then it shows the use of IHostBuilder.

The UseNLog extension method for IHostBuilder has been added with this PR #335 (Available with NLog.Web.AspNetCore ver. 4.8.0)

What else is missing to support NetCore3?

@repo-ranger
Copy link
Contributor

repo-ranger bot commented Sep 18, 2019

Please add the requested info, so we could help you better! (This issue will be closed in 7 days)

@304NotModified
Copy link
Member

bump @jasonycw

@mareklinka
Copy link

It looks like IHostingEnvironment has been replaced with IWebHostEnvironment which does not support the ConfigureNLog method. Is there an alternative way of specifying what file to read the configuration from?

@304NotModified
Copy link
Member

304NotModified commented Sep 24, 2019

I guess we need to make an extension on IWebHostEnvironment then

For now you could assign LogManager.Configuration with new XmlLoggingConfiguration(path)

@snakefoot
Copy link
Contributor

snakefoot commented Sep 24, 2019

@mareklinka Just curious why do you need extension-methods for IHostEnvironment-interface ?

Why not just use the IHostBuilder as recommended by all NetCore3 samples? (NLog already includes a UseNLog-extension-method)

@mareklinka
Copy link

I don't think we necessarily need the extension method. I was just migrating our existing code base and the project was using the ConfigureNLog extension method since its inception (Core 2.0). I will need to rewrite the host buildup anyway for Core 3.0, I might as well rewrite the logging configuration. Thanks for pointing me to the recommended practice.

@snakefoot
Copy link
Contributor

snakefoot commented Sep 24, 2019

@mareklinka Think the correct approach for NLog.Extension.Logging and NLog.Web.AspNetCore is to obsolete all usage of ILoggerFactory and IHostingEnvironment for NetStandard2 (And redirect to IHostBuilder and ILoggingBuilder)

@snakefoot
Copy link
Contributor

snakefoot commented Sep 24, 2019

Created #478 and NLog/NLog.Extensions.Logging#342 and #483

@304NotModified
Copy link
Member

Fixed by those PRs :)

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

No branches or pull requests

4 participants