Skip to content

Commit

Permalink
ILoggerFactory is obsolete in .NET Core 3. Instead use ILoggingBuilde…
Browse files Browse the repository at this point in the history
…r.AddNLog (#342)

* ILoggerFactory is obsolete in NetCore3. Instead use ILoggingBuilder.AddNLog() or IHostBuilder.UseNLog()

* Version 1.6.0

* Updated to NLog 4.6.7

* Update CHANGELOG.MD
  • Loading branch information
snakefoot authored and 304NotModified committed Sep 24, 2019
1 parent 38d3410 commit b3df47c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Date format: (year/month/day)

### v1.6.0 (2019/09/24)
- [#342](https://github.com/NLog/NLog.Extensions.Logging/pull/342) ILoggerFactory is obsolete in .NET Core 3. Instead use ILoggingBuilder.AddNLog
- [#333](https://github.com/NLog/NLog.Extensions.Logging/pull/333) + [#334](https://github.com/NLog/NLog.Extensions.Logging/pull/334) Minor optimization in parsing of LogEvent property-names

### v1.5.4 (2019/09/06)
- [#325](https://github.com/NLog/NLog.Extensions.Logging/pull/325) Fix dispose for AddNLog (on ILoggingBuilder) and no double logging when also using UseNLog (@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 = "1.5.4"
$versionPrefix = "1.6.0"
$versionSuffix = ""
$versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER}
$versionProduct = $versionPrefix;
Expand Down
9 changes: 9 additions & 0 deletions src/NLog.Extensions.Logging/Extensions/ConfigureExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public static class ConfigureExtensions
/// </summary>
/// <param name="factory"></param>
/// <returns>ILoggerFactory for chaining</returns>
#if !NETCORE1_0
[Obsolete("Instead use ILoggingBuilder.AddNLog() or IHostBuilder.UseNLog()")]
#endif
public static ILoggerFactory AddNLog(this ILoggerFactory factory)
{
return factory.AddNLog(NLogProviderOptions.Default);
Expand All @@ -33,6 +36,9 @@ public static ILoggerFactory AddNLog(this ILoggerFactory factory)
/// <param name="factory"></param>
/// <param name="options">NLog options</param>
/// <returns>ILoggerFactory for chaining</returns>
#if !NETCORE1_0
[Obsolete("Instead use ILoggingBuilder.AddNLog() or IHostBuilder.UseNLog()")]
#endif
public static ILoggerFactory AddNLog(this ILoggerFactory factory, NLogProviderOptions options)
{
factory.AddProvider(new NLogLoggerProvider(options));
Expand All @@ -45,6 +51,9 @@ public static ILoggerFactory AddNLog(this ILoggerFactory factory, NLogProviderOp
/// <param name="factory"></param>
/// <param name="configuration"></param>
/// <returns>ILoggerFactory for chaining</returns>
#if !NETCORE1_0
[Obsolete("Instead use ILoggingBuilder.AddNLog() or IHostBuilder.UseNLog()")]
#endif
public static ILoggerFactory AddNLog(this ILoggerFactory factory, IConfiguration configuration)
{
var provider = CreateNLogProvider(configuration);
Expand Down
6 changes: 4 additions & 2 deletions src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ For ASP.NET Core, use NLog.Web.AspNetCore: https://www.nuget.org/packages/NLog.W
</Description>
<PackageTags>NLog;Microsoft.Extensions.Logging;log;logging;logfiles;netcore</PackageTags>
<PackageReleaseNotes>
- Fix dispose for AddNLog (on ILoggingBuilder) and no double logging when also using UseNLog (@snakefoot)
- Marked ILoggerFactory extension methods as obsolete, since obsolete in NetCore3
- Minor optimization in parsing of LogEvent property-names
- Updated NLog dependency

Full changelog: https://github.com/NLog/NLog.Extensions.Logging/blob/master/CHANGELOG.MD
</PackageReleaseNotes>
Expand Down Expand Up @@ -58,7 +60,7 @@ Full changelog: https://github.com/NLog/NLog.Extensions.Logging/blob/master/CHAN
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="[4.6.5,5.0.0-beta01)" />
<PackageReference Include="NLog" Version="[4.6.7,5.0.0-beta01)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="1.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace NLog.Extensions.Logging.Tests.Extensions
public class ConfigureExtensionsTests
{
[Fact]
[Obsolete("Instead use ILoggingBuilder.AddNLog() or IHostBuilder.UseNLog()")]
public void AddNLog_LoggerFactory_LogInfo_ShouldLogToNLog()
{
// Arrange
Expand All @@ -32,6 +33,7 @@ public void AddNLog_LoggerFactory_LogInfo_ShouldLogToNLog()
[InlineData("EventId", "eventId2")]
[InlineData("EventId_Name", "eventId2")]
[InlineData("EventId_Id", "2")]
[Obsolete("Instead use ILoggingBuilder.AddNLog() or IHostBuilder.UseNLog()")]
public void AddNLog_LoggerFactory_LogInfoWithEventId_ShouldLogToNLogWithEventId(string eventPropery, string expectedEventInLog)
{
// Arrange
Expand Down

0 comments on commit b3df47c

Please sign in to comment.