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

ASP.NET Core: Improved ConfigureNLog for better out-of-the-box experience #268

Merged
merged 1 commit into from
Apr 2, 2018

Conversation

snakefoot
Copy link
Contributor

@snakefoot snakefoot commented Apr 1, 2018

NLogBuilder is needed, because DLL autoload doesn't work - this will replace replace LoadConfiguration with ConfigureNLog

unless the DLL has been loaded.

Resolves #267 + Resolves #264

The example project was cheating as it had a direct reference to "NLog.Web.AspNetCore". After removing project-reference and using nuget-package, then it pre-loaded differently.

@codecov
Copy link

codecov bot commented Apr 1, 2018

Codecov Report

Merging #268 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #268   +/-   ##
=====================================
  Coverage      57%    57%           
=====================================
  Files          31     31           
  Lines         407    407           
  Branches       92     92           
=====================================
  Hits          233    233           
  Misses        138    138           
  Partials       36     36

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f94df3...72b805c. Read the comment docs.

@@ -11,7 +11,7 @@ public static class Program
{
public static void Main(string[] args)
{
var logger = NLog.LogManager.LoadConfiguration("nlog.config").GetCurrentClassLogger();
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm maybe this needs a minor version change, because of changed api usage.

(4.6 instead of 4.5.1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the two bug-issues has shown, then 4.5.0 is not working that well out of the box (actually very broken). Think 4.5.1 would be fine. Unless you have a good idea for how to pre-register when AspNetCore?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks, NLog.LogManager.LoadConfiguration still works of course (in the same bugged way)

@304NotModified 304NotModified merged commit 1bfddc9 into NLog:master Apr 2, 2018
@304NotModified 304NotModified changed the title NLogBuilder is needed, because DLL autoload doesn't work ASP.NET Core: replace LoadConfiguration with ConfigureNLog, for better out-of-box experience Apr 2, 2018
@304NotModified 304NotModified changed the title ASP.NET Core: replace LoadConfiguration with ConfigureNLog, for better out-of-box experience ASP.NET Core: replace LoadConfiguration with ConfigureNLog, for better out-of-the-box experience Apr 2, 2018
@304NotModified
Copy link
Member

@304NotModified 304NotModified changed the title ASP.NET Core: replace LoadConfiguration with ConfigureNLog, for better out-of-the-box experience ASP.NET Core: improved ConfigureNLog for better out-of-the-box experience Apr 2, 2018
@304NotModified 304NotModified changed the title ASP.NET Core: improved ConfigureNLog for better out-of-the-box experience ASP.NET Core: Improved ConfigureNLog for better out-of-the-box experience Apr 2, 2018
@snakefoot
Copy link
Contributor Author

Maybe AddNLog(this ILoggingBuilder factory) should be fixed to auto register Microsoft.Extensions.Logging.Abstraction as hidden assembly for better callsite-experience (Also for NetCore2)

@304NotModified
Copy link
Member

304NotModified commented Apr 2, 2018

Yes, I think that's a good idea.

PS: Now building a new release for nlog.web.aspnetcore

@304NotModified
Copy link
Member

release will be probably "tomorrow".

Have a good night!

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

Successfully merging this pull request may close these issues.

2 participants