Skip to content

Commit f633c9f

Browse files
authored
Version 5.3.11 (#745)
1 parent aee360f commit f633c9f

File tree

5 files changed

+44
-39
lines changed

5 files changed

+44
-39
lines changed

CHANGELOG.MD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
Date format: (year/month/day)
44

5+
### Version 5.3.11 (2024/05/07)
6+
7+
**Improvements**
8+
- [#745](https://github.com/NLog/NLog.Extensions.Logging/pull/745): Fixed CallSite-logic for NLog.Web.AspNetCore (#745) (@snakefoot)
9+
510
### Version 5.3.10 (2024/04/30)
11+
612
**Improvements**
713
- [#742](https://github.com/NLog/NLog.Extensions.Logging/pull/742): Improve auto ordering of variables-section when dependent variables (#742) (@snakefoot)
814
- [#743](https://github.com/NLog/NLog.Extensions.Logging/pull/743): Updated to NLog v5.3.2 (#743) (@snakefoot)
915

1016
### Version 5.3.9 (2024/04/27)
17+
1118
**Improvements**
1219
- [#724](https://github.com/NLog/NLog.Extensions.Logging/pull/724): Skipping empty config sections without throwing exceptions (#724) (@RodionovDmitry)
1320
- [#737](https://github.com/NLog/NLog.Extensions.Logging/pull/737): Auto ordering of variables-section when dependent variables (#737) (@snakefoot)

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# creates NuGet package at \artifacts
33
dotnet --version
44

5-
$versionPrefix = "5.3.10"
5+
$versionPrefix = "5.3.11"
66
$versionSuffix = ""
77
$versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER}
88
$versionProduct = $versionPrefix;

src/NLog.Extensions.Logging/Config/SetupExtensionsBuilderExtensions.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,44 @@ public static class SetupExtensionsBuilderExtensions
1717
public static ISetupExtensionsBuilder RegisterConfigSettings(this ISetupExtensionsBuilder setupBuilder, IConfiguration configuration)
1818
{
1919
ConfigSettingLayoutRenderer.DefaultConfiguration = configuration ?? ConfigSettingLayoutRenderer.DefaultConfiguration;
20+
setupBuilder.LogFactory.Setup().SetupLogFactory(ext =>
21+
{
22+
ext.AddCallSiteHiddenAssembly(typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
23+
ext.AddCallSiteHiddenAssembly(typeof(Microsoft.Extensions.Logging.ILogger).GetTypeInfo().Assembly);
24+
#if !NETCORE1_0
25+
ext.AddCallSiteHiddenAssembly(typeof(Microsoft.Extensions.Logging.LoggerFactory).GetTypeInfo().Assembly);
26+
#else
27+
var loggingAssembly = SafeLoadHiddenAssembly("Microsoft.Logging");
28+
ext.AddCallSiteHiddenAssembly(loggingAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
29+
var extensionAssembly = SafeLoadHiddenAssembly("Microsoft.Extensions.Logging");
30+
ext.AddCallSiteHiddenAssembly(extensionAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
31+
var filterAssembly = SafeLoadHiddenAssembly("Microsoft.Extensions.Logging.Filter", false);
32+
ext.AddCallSiteHiddenAssembly(filterAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
33+
#endif
34+
});
2035
return setupBuilder.RegisterLayoutRenderer<ConfigSettingLayoutRenderer>("configsetting")
2136
.RegisterLayoutRenderer<MicrosoftConsoleLayoutRenderer>("MicrosoftConsoleLayout")
2237
.RegisterLayout<MicrosoftConsoleJsonLayout>("MicrosoftConsoleJsonLayout")
2338
.RegisterTarget<MicrosoftILoggerTarget>("MicrosoftILogger");
2439
}
40+
41+
#if NETCORE1_0
42+
private static Assembly SafeLoadHiddenAssembly(string assemblyName, bool logOnException = true)
43+
{
44+
try
45+
{
46+
InternalLogger.Debug("Loading Assembly {0} to mark it as hidden for callsite", assemblyName);
47+
return Assembly.Load(new AssemblyName(assemblyName));
48+
}
49+
catch (Exception ex)
50+
{
51+
if (logOnException)
52+
{
53+
InternalLogger.Debug(ex, "Failed loading Loading Assembly {0} to mark it as hidden for callsite", assemblyName);
54+
}
55+
return null;
56+
}
57+
}
58+
#endif
2559
}
2660
}

src/NLog.Extensions.Logging/Internal/RegisterNLogLoggingProvider.cs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -92,43 +92,8 @@ internal static NLogLoggerProvider CreateNLogLoggerProvider(this IServiceProvide
9292
internal static IConfiguration SetupNLogConfigSettings(this IServiceProvider serviceProvider, IConfiguration configuration, LogFactory logFactory)
9393
{
9494
configuration = configuration ?? (serviceProvider?.GetService(typeof(IConfiguration)) as IConfiguration);
95-
logFactory.Setup()
96-
.SetupExtensions(ext => ext.RegisterConfigSettings(configuration))
97-
.SetupLogFactory(ext =>
98-
{
99-
ext.AddCallSiteHiddenAssembly(typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
100-
ext.AddCallSiteHiddenAssembly(typeof(Microsoft.Extensions.Logging.ILogger).GetTypeInfo().Assembly);
101-
#if !NETCORE1_0
102-
ext.AddCallSiteHiddenAssembly(typeof(Microsoft.Extensions.Logging.LoggerFactory).GetTypeInfo().Assembly);
103-
#else
104-
var loggingAssembly = SafeLoadHiddenAssembly("Microsoft.Logging");
105-
ext.AddCallSiteHiddenAssembly(loggingAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
106-
var extensionAssembly = SafeLoadHiddenAssembly("Microsoft.Extensions.Logging");
107-
ext.AddCallSiteHiddenAssembly(extensionAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
108-
var filterAssembly = SafeLoadHiddenAssembly("Microsoft.Extensions.Logging.Filter", false);
109-
ext.AddCallSiteHiddenAssembly(filterAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
110-
#endif
111-
});
95+
logFactory.Setup().SetupExtensions(ext => ext.RegisterConfigSettings(configuration));
11296
return configuration;
11397
}
114-
115-
#if NETCORE1_0
116-
private static Assembly SafeLoadHiddenAssembly(string assemblyName, bool logOnException = true)
117-
{
118-
try
119-
{
120-
Common.InternalLogger.Debug("Loading Assembly {0} to mark it as hidden for callsite", assemblyName);
121-
return Assembly.Load(new AssemblyName(assemblyName));
122-
}
123-
catch (Exception ex)
124-
{
125-
if (logOnException)
126-
{
127-
Common.InternalLogger.Debug(ex, "Failed loading Loading Assembly {0} to mark it as hidden for callsite", assemblyName);
128-
}
129-
return null;
130-
}
131-
}
132-
#endif
13398
}
13499
}

src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ For ASP.NET Core, check: https://www.nuget.org/packages/NLog.Web.AspNetCore
1818
<PackageReleaseNotes>
1919
ChangeLog:
2020

21-
- Improve auto ordering of variables-section when dependent variables (#742) (@snakefoot)
22-
- Updated to NLog v5.3.2 (#743) (@snakefoot)
21+
- Fixed CallSite-Logic for NLog.Web.AspNetCore (#745) (@snakefoot)
2322

2423
Full changelog: https://github.com/NLog/NLog.Extensions.Logging/blob/master/CHANGELOG.MD
2524

0 commit comments

Comments
 (0)