From 4a988ad49914b6d1277f980253a503ad9b202e2f Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Fri, 13 Oct 2017 21:20:49 +0200 Subject: [PATCH] Fix callsite fixes https://github.com/NLog/NLog.Web/issues/200 --- NLog.Web.AspNetCore/AspNetExtensions.cs | 5 ++++- NLog.Web.AspNetCore/NLogBuilder.cs | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NLog.Web.AspNetCore/AspNetExtensions.cs b/NLog.Web.AspNetCore/AspNetExtensions.cs index 432d7b2c..61fb0b48 100644 --- a/NLog.Web.AspNetCore/AspNetExtensions.cs +++ b/NLog.Web.AspNetCore/AspNetExtensions.cs @@ -72,7 +72,7 @@ private static LoggingConfiguration ConfigureNLog(string fileName) /// LogFactory to get loggers, add events etc public static LogFactory ConfigureNLog(this ILoggingBuilder builder, string configFileName) { - return NLogBuilder.ConfigureNLog(configFileName); + return builder.ConfigureNLog(new XmlLoggingConfiguration(configFileName)); } /// @@ -85,6 +85,9 @@ public static LogFactory ConfigureNLog(this ILoggingBuilder builder, string conf /// LogFactory to get loggers, add events etc public static LogFactory ConfigureNLog(this ILoggingBuilder builder, LoggingConfiguration configuration) { + //ConfigureHiddenAssemblies + //todo rename there to ConfigureNLog? + builder.AddNLog(); return NLogBuilder.ConfigureNLog(configuration); } diff --git a/NLog.Web.AspNetCore/NLogBuilder.cs b/NLog.Web.AspNetCore/NLogBuilder.cs index 92117d54..0a42f453 100644 --- a/NLog.Web.AspNetCore/NLogBuilder.cs +++ b/NLog.Web.AspNetCore/NLogBuilder.cs @@ -30,6 +30,14 @@ internal static void RegisterNLogWebAspNetCore() { InternalLogger.Error(ex, "Registering NLog.Web.AspNetCore failed"); } + try + { + LogManager.AddHiddenAssembly(typeof(NLogBuilder).GetTypeInfo().Assembly); + } + catch (Exception ex) + { + InternalLogger.Warn(ex, "Hidding assembly of {0} failed", nameof(NLogBuilder)); + } }