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

Version 5.3.11 #745

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

Date format: (year/month/day)

### Version 5.3.11 (2024/05/07)

**Improvements**
- [#745](https://github.com/NLog/NLog.Extensions.Logging/pull/745): Fixed CallSite-logic for NLog.Web.AspNetCore (#745) (@snakefoot)

### Version 5.3.10 (2024/04/30)

**Improvements**
- [#742](https://github.com/NLog/NLog.Extensions.Logging/pull/742): Improve auto ordering of variables-section when dependent variables (#742) (@snakefoot)
- [#743](https://github.com/NLog/NLog.Extensions.Logging/pull/743): Updated to NLog v5.3.2 (#743) (@snakefoot)

### Version 5.3.9 (2024/04/27)

**Improvements**
- [#724](https://github.com/NLog/NLog.Extensions.Logging/pull/724): Skipping empty config sections without throwing exceptions (#724) (@RodionovDmitry)
- [#737](https://github.com/NLog/NLog.Extensions.Logging/pull/737): Auto ordering of variables-section when dependent variables (#737) (@snakefoot)
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# creates NuGet package at \artifacts
dotnet --version

$versionPrefix = "5.3.10"
$versionPrefix = "5.3.11"
$versionSuffix = ""
$versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER}
$versionProduct = $versionPrefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,44 @@ public static class SetupExtensionsBuilderExtensions
public static ISetupExtensionsBuilder RegisterConfigSettings(this ISetupExtensionsBuilder setupBuilder, IConfiguration configuration)
{
ConfigSettingLayoutRenderer.DefaultConfiguration = configuration ?? ConfigSettingLayoutRenderer.DefaultConfiguration;
setupBuilder.LogFactory.Setup().SetupLogFactory(ext =>
{
ext.AddCallSiteHiddenAssembly(typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
ext.AddCallSiteHiddenAssembly(typeof(Microsoft.Extensions.Logging.ILogger).GetTypeInfo().Assembly);
#if !NETCORE1_0
ext.AddCallSiteHiddenAssembly(typeof(Microsoft.Extensions.Logging.LoggerFactory).GetTypeInfo().Assembly);
#else
var loggingAssembly = SafeLoadHiddenAssembly("Microsoft.Logging");
ext.AddCallSiteHiddenAssembly(loggingAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
var extensionAssembly = SafeLoadHiddenAssembly("Microsoft.Extensions.Logging");
ext.AddCallSiteHiddenAssembly(extensionAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
var filterAssembly = SafeLoadHiddenAssembly("Microsoft.Extensions.Logging.Filter", false);
ext.AddCallSiteHiddenAssembly(filterAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
#endif
});
return setupBuilder.RegisterLayoutRenderer<ConfigSettingLayoutRenderer>("configsetting")
.RegisterLayoutRenderer<MicrosoftConsoleLayoutRenderer>("MicrosoftConsoleLayout")
.RegisterLayout<MicrosoftConsoleJsonLayout>("MicrosoftConsoleJsonLayout")
.RegisterTarget<MicrosoftILoggerTarget>("MicrosoftILogger");
}

#if NETCORE1_0
private static Assembly SafeLoadHiddenAssembly(string assemblyName, bool logOnException = true)
{
try
{
InternalLogger.Debug("Loading Assembly {0} to mark it as hidden for callsite", assemblyName);
return Assembly.Load(new AssemblyName(assemblyName));
}
catch (Exception ex)
{
if (logOnException)
{
InternalLogger.Debug(ex, "Failed loading Loading Assembly {0} to mark it as hidden for callsite", assemblyName);
}
return null;
}
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,43 +92,8 @@ internal static NLogLoggerProvider CreateNLogLoggerProvider(this IServiceProvide
internal static IConfiguration SetupNLogConfigSettings(this IServiceProvider serviceProvider, IConfiguration configuration, LogFactory logFactory)
{
configuration = configuration ?? (serviceProvider?.GetService(typeof(IConfiguration)) as IConfiguration);
logFactory.Setup()
.SetupExtensions(ext => ext.RegisterConfigSettings(configuration))
.SetupLogFactory(ext =>
{
ext.AddCallSiteHiddenAssembly(typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
ext.AddCallSiteHiddenAssembly(typeof(Microsoft.Extensions.Logging.ILogger).GetTypeInfo().Assembly);
#if !NETCORE1_0
ext.AddCallSiteHiddenAssembly(typeof(Microsoft.Extensions.Logging.LoggerFactory).GetTypeInfo().Assembly);
#else
var loggingAssembly = SafeLoadHiddenAssembly("Microsoft.Logging");
ext.AddCallSiteHiddenAssembly(loggingAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
var extensionAssembly = SafeLoadHiddenAssembly("Microsoft.Extensions.Logging");
ext.AddCallSiteHiddenAssembly(extensionAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
var filterAssembly = SafeLoadHiddenAssembly("Microsoft.Extensions.Logging.Filter", false);
ext.AddCallSiteHiddenAssembly(filterAssembly ?? typeof(NLogLoggerProvider).GetTypeInfo().Assembly);
#endif
});
logFactory.Setup().SetupExtensions(ext => ext.RegisterConfigSettings(configuration));
return configuration;
}

#if NETCORE1_0
private static Assembly SafeLoadHiddenAssembly(string assemblyName, bool logOnException = true)
{
try
{
Common.InternalLogger.Debug("Loading Assembly {0} to mark it as hidden for callsite", assemblyName);
return Assembly.Load(new AssemblyName(assemblyName));
}
catch (Exception ex)
{
if (logOnException)
{
Common.InternalLogger.Debug(ex, "Failed loading Loading Assembly {0} to mark it as hidden for callsite", assemblyName);
}
return null;
}
}
#endif
}
}
3 changes: 1 addition & 2 deletions src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ For ASP.NET Core, check: https://www.nuget.org/packages/NLog.Web.AspNetCore
<PackageReleaseNotes>
ChangeLog:

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

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

Expand Down