Skip to content

Commit c28a9e8

Browse files
Merge pull request #316 from NLog/release/1.5.2
Release 1.5.2
2 parents 896e715 + cb6a873 commit c28a9e8

23 files changed

+740
-160
lines changed

CHANGELOG.MD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

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

5+
### v1.5.2 (2019/07/14)
6+
- [#314](https://github.com/NLog/NLog.Extensions.Logging/pull/314) Added NLogProviderOptions.ShutdownOnDispose (#314) (@304NotModified)
7+
- [#315](https://github.com/NLog/NLog.Extensions.Logging/pull/315) Update NLog to 4.6.5 (#315) (@304NotModified)
8+
59
### V1.5.1 (2019/06/05)
610
- [#289](https://github.com/NLog/NLog.Extensions.Logging/pull/289) NLogBeginScopeParser - Improved exception handling (@snakefoot)
711
- [#299](https://github.com/NLog/NLog.Extensions.Logging/pull/299) Update dependency NLog ver. 4.6.4 (@snakefoot)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=appsetting/@EntryIndexedValue">True</s:Boolean>
3+
<s:Boolean x:Key="/Default/UserDictionary/Words/=configsetting/@EntryIndexedValue">True</s:Boolean>
4+
<s:Boolean x:Key="/Default/UserDictionary/Words/=mldc/@EntryIndexedValue">True</s:Boolean>
5+
<s:Boolean x:Key="/Default/UserDictionary/Words/=ndlc/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
# NLog.Extensions.Logging
1+
![NLog](https://nlog-project.org/images/NLog.png)
2+
3+
# NLog.Extensions.Logging
24

35

46

57
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/NLog.Extensions.Logging.svg)](https://www.nuget.org/packages/NLog.Extensions.Logging)
6-
[![Build status Windows](https://ci.appveyor.com/api/projects/status/0nrg8cksp4b6tab1/branch/master?svg=true)](https://ci.appveyor.com/project/nlog/nlog-framework-logging/branch/master)
8+
[![Build status Windows](https://ci.appveyor.com/api/projects/status/0nrg8cksp4b6tab1/branch/dev?svg=true)](https://ci.appveyor.com/project/nlog/nlog-framework-logging/branch/dev)
79
[![Build Status Linux](https://travis-ci.org/NLog/NLog.Extensions.Logging.svg?branch=master)](https://travis-ci.org/NLog/NLog.Extensions.Logging)
810

9-
[![BCH compliance](https://bettercodehub.com/edge/badge/NLog/NLog.Extensions.Logging?branch=components)](https://bettercodehub.com/results/NLog/NLog.Extensions.Logging)
10-
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=ncloc)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging)
11-
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=bugs)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging)
12-
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=vulnerabilities)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging)
13-
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=code_smells)](https://sonarcloud.io/project/issues?id=nlog.extensions.logging&resolved=false&types=CODE_SMELL)
14-
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=duplicated_lines_density)](https://sonarcloud.io/component_measures/domain/Duplications?id=nlog.extensions.logging)
15-
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=sqale_debt_ratio)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging)
16-
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=coverage)](https://sonarcloud.io/component_measures?id=nlog.extensions.logging&metric=coverage)
11+
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=ncloc)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging&branch=dev)
12+
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=bugs)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging&branch=dev)
13+
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=vulnerabilities)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging&branch=dev)
14+
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=code_smells)](https://sonarcloud.io/project/issues?id=nlog.extensions.logging&branch=dev&resolved=false&types=CODE_SMELL)
15+
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=duplicated_lines_density)](https://sonarcloud.io/component_measures/domain/Duplications?id=nlog.extensions.logging&branch=dev)
16+
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=sqale_debt_ratio)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging&branch=dev)
17+
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=coverage)](https://sonarcloud.io/component_measures?id=nlog.extensions.logging&branch=dev&metric=coverage)
1718

1819
[NLog](https://github.com/NLog/NLog) provider for [Microsoft.Extensions.Logging](https://github.com/aspnet/Logging); .NET Core.
1920
**ASP.NET Core** users should install [NLog.Web.AspNetCore](https://www.nuget.org/packages/NLog.web.aspnetcore).

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 = "1.5.1"
5+
$versionPrefix = "1.5.2"
66
$versionSuffix = ""
77
$versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER}
88
$versionProduct = $versionPrefix;

src/NLog.Extensions.Hosting/NLog.Extensions.Hosting.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Full changelog: https://github.com/NLog/NLog.Extensions.Logging/blob/master/CHAN
2828
<AssemblyVersion>1.0.0.0</AssemblyVersion>
2929
<AssemblyOriginatorKeyFile>..\NLog.snk</AssemblyOriginatorKeyFile>
3030
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
31+
<LangVersion>latest</LangVersion>
3132
</PropertyGroup>
3233

3334
<ItemGroup>

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public override IEnumerable<string> FileNamesToWatch
4747
if (_autoReload && _reloadConfiguration == null)
4848
{
4949
// Prepare for setting up reload notification handling
50-
_reloadConfiguration = state => ReloadConfigurationSection((IConfigurationSection) state);
50+
_reloadConfiguration = state => ReloadConfigurationSection((IConfigurationSection)state);
5151
LogFactory.ConfigurationChanged += LogFactory_ConfigurationChanged;
5252
}
5353

@@ -128,8 +128,8 @@ private class LoggingConfigurationElement : ILoggingConfigurationElement
128128
private const string VariableKey = "Variable";
129129
private const string DefaultWrapper = "Default-wrapper";
130130
private readonly IConfigurationSection _configurationSection;
131-
public IConfigurationSection DefaultTargetParametersSection { get; set; }
132-
public IConfigurationSection DefaultTargetWrapperSection { get; set; }
131+
private IConfigurationSection DefaultTargetParametersSection { get; set; }
132+
private IConfigurationSection DefaultTargetWrapperSection { get; set; }
133133
private readonly string _nameOverride;
134134
private readonly bool _topElement;
135135

@@ -138,9 +138,9 @@ public LoggingConfigurationElement(IConfigurationSection configurationSection, b
138138
_configurationSection = configurationSection;
139139
_nameOverride = nameOverride;
140140
_topElement = topElement;
141-
if (topElement && bool.TryParse(configurationSection["autoreload"], out var autoreload))
141+
if (topElement && bool.TryParse(configurationSection["autoreload"], out var autoReload))
142142
{
143-
AutoReload = autoreload;
143+
AutoReload = autoReload;
144144
}
145145
}
146146

@@ -191,8 +191,6 @@ private IEnumerable<ILoggingConfigurationElement> GetChildren()
191191
}
192192

193193
var isTargetsSection = IsTargetsSection();
194-
var defaultTargetWrapper = GetDefaultWrapperSection();
195-
var defaultTargetParameters = GetDefaultTargetParametersSection();
196194

197195
if (isTargetsSection)
198196
{
@@ -203,9 +201,19 @@ private IEnumerable<ILoggingConfigurationElement> GetChildren()
203201
}
204202

205203
var children = _configurationSection.GetChildren();
204+
foreach (var loggingConfigurationElement in GetChildren(children, variables, isTargetsSection))
205+
{
206+
yield return loggingConfigurationElement;
207+
}
208+
}
209+
210+
private IEnumerable<ILoggingConfigurationElement> GetChildren(IEnumerable<IConfigurationSection> children, IConfigurationSection variables, bool isTargetsSection)
211+
{
212+
var defaultTargetWrapper = GetDefaultWrapperSection();
213+
var defaultTargetParameters = GetDefaultTargetParametersSection();
206214
foreach (var child in children)
207215
{
208-
if (AlreadReadChild(child, variables, defaultTargetWrapper, defaultTargetParameters))
216+
if (AlreadyReadChild(child, variables, defaultTargetWrapper, defaultTargetParameters))
209217
{
210218
continue;
211219
}
@@ -222,10 +230,11 @@ private IEnumerable<ILoggingConfigurationElement> GetChildren()
222230
}
223231
else
224232
{
233+
var isTargetKey = child.Key.EqualsOrdinalIgnoreCase(TargetsKey);
225234
yield return new LoggingConfigurationElement(child, false, isTargetsSection ? TargetKey : null)
226235
{
227-
DefaultTargetParametersSection = (defaultTargetParameters != null && child.Key.EqualsOrdinalIgnoreCase(TargetsKey)) ? defaultTargetParameters : null,
228-
DefaultTargetWrapperSection = (defaultTargetWrapper != null && child.Key.EqualsOrdinalIgnoreCase(TargetsKey)) ? defaultTargetWrapper : null,
236+
DefaultTargetParametersSection = (defaultTargetParameters != null && isTargetKey) ? defaultTargetParameters : null,
237+
DefaultTargetWrapperSection = (defaultTargetWrapper != null && isTargetKey) ? defaultTargetWrapper : null,
229238
};
230239
}
231240
}
@@ -260,7 +269,7 @@ private IEnumerable<LoggingConfigurationElement> GetTargetsDefaultConfigElements
260269
}
261270
}
262271

263-
private bool AlreadReadChild(IConfigurationSection child, IConfigurationSection variables, IConfigurationSection defaultWrapper, IConfigurationSection defaultTargetParameters)
272+
private bool AlreadyReadChild(IConfigurationSection child, IConfigurationSection variables, IConfigurationSection defaultWrapper, IConfigurationSection defaultTargetParameters)
264273
{
265274
if (_topElement)
266275
{

src/NLog.Extensions.Logging/LayoutRenderers/ConfigSettingLayoutRenderer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using Microsoft.Extensions.Configuration;
43
using NLog.Common;
54
using NLog.Config;
@@ -46,7 +45,7 @@ public class ConfigSettingLayoutRenderer : LayoutRenderer
4645
[DefaultParameter]
4746
public string Item
4847
{
49-
get { return _item; }
48+
get => _item;
5049
set
5150
{
5251
_item = value;

src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static IDisposable CaptureScopeProperties(IReadOnlyList<KeyValuePair<stri
113113
return CreateScopeProperties(scopeObject, scopePropertyList);
114114
}
115115

116-
public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollection, ExtractorDictionary stateExractor)
116+
public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollection, ExtractorDictionary stateExtractor)
117117
{
118118
List<KeyValuePair<string, object>> propertyList = null;
119119

@@ -125,7 +125,7 @@ public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollec
125125
break;
126126
}
127127

128-
if (keyValueExtractor.Key == null && !TryLookupExtractor(stateExractor, property.GetType(), out keyValueExtractor))
128+
if (keyValueExtractor.Key == null && !TryLookupExtractor(stateExtractor, property.GetType(), out keyValueExtractor))
129129
{
130130
break;
131131
}
@@ -143,9 +143,9 @@ public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollec
143143
return CreateScopeProperties(scopePropertyCollection, propertyList);
144144
}
145145

146-
public static IDisposable CaptureScopeProperty<TState>(TState scopeProperty, ExtractorDictionary stateExractor)
146+
public static IDisposable CaptureScopeProperty<TState>(TState scopeProperty, ExtractorDictionary stateExtractor)
147147
{
148-
if (!TryLookupExtractor(stateExractor, scopeProperty.GetType(), out var keyValueExtractor))
148+
if (!TryLookupExtractor(stateExtractor, scopeProperty.GetType(), out var keyValueExtractor))
149149
{
150150
return NestedDiagnosticsLogicalContext.Push(scopeProperty);
151151
}
@@ -177,10 +177,10 @@ public static IDisposable CaptureScopeProperty<TState>(TState scopeProperty, Ext
177177
}
178178
}
179179

180-
private static bool TryLookupExtractor(ExtractorDictionary stateExractor, Type propertyType,
180+
private static bool TryLookupExtractor(ExtractorDictionary stateExtractor, Type propertyType,
181181
out KeyValuePair<Func<object, object>, Func<object, object>> keyValueExtractor)
182182
{
183-
if (!stateExractor.TryGetValue(propertyType, out keyValueExtractor))
183+
if (!stateExtractor.TryGetValue(propertyType, out keyValueExtractor))
184184
{
185185
try
186186
{
@@ -192,7 +192,7 @@ private static bool TryLookupExtractor(ExtractorDictionary stateExractor, Type p
192192
}
193193
finally
194194
{
195-
stateExractor[propertyType] = keyValueExtractor;
195+
stateExtractor[propertyType] = keyValueExtractor;
196196
}
197197
}
198198

@@ -201,7 +201,7 @@ private static bool TryLookupExtractor(ExtractorDictionary stateExractor, Type p
201201

202202
private static bool TryBuildExtractor(Type propertyType, out KeyValuePair<Func<object, object>, Func<object, object>> keyValueExtractor)
203203
{
204-
keyValueExtractor = default(KeyValuePair<Func<object, object>, Func<object, object>>);
204+
keyValueExtractor = default;
205205

206206
var itemType = propertyType.GetTypeInfo();
207207
if (!itemType.IsGenericType || itemType.GetGenericTypeDefinition() != typeof(KeyValuePair<,>))

0 commit comments

Comments
 (0)