From ceb10bb2274e8ada3d77aaa75f4a421a05bd8866 Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Thu, 30 May 2019 12:24:02 +0200 Subject: [PATCH 01/15] RetryingMultiProcessFileAppender - BufferSize should match byte-count --- .../Internal/FileAppenders/BaseFileAppender.cs | 17 +++++++++-------- .../RetryingMultiProcessFileAppender.cs | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/NLog/Internal/FileAppenders/BaseFileAppender.cs b/src/NLog/Internal/FileAppenders/BaseFileAppender.cs index 0ed3daeb9c..0bd10c1e08 100644 --- a/src/NLog/Internal/FileAppenders/BaseFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/BaseFileAppender.cs @@ -163,8 +163,9 @@ protected virtual void Dispose(bool disposing) /// Creates the file stream. /// /// If set to true sets the file stream to allow shared writing. + /// If larger than 0 then it will be used instead of the default BufferSize for the FileStream. /// A object which can be used to write to the file. - protected FileStream CreateFileStream(bool allowFileSharedWriting) + protected FileStream CreateFileStream(bool allowFileSharedWriting, int overrideBufferSize = 0) { int currentDelay = CreateFileParameters.ConcurrentWriteAttemptDelay; @@ -175,7 +176,7 @@ protected FileStream CreateFileStream(bool allowFileSharedWriting) { try { - return TryCreateFileStream(allowFileSharedWriting); + return TryCreateFileStream(allowFileSharedWriting, overrideBufferSize); } catch (DirectoryNotFoundException) { @@ -194,7 +195,7 @@ protected FileStream CreateFileStream(bool allowFileSharedWriting) //if creating a directory failed, don't retry for this message (e.g the ConcurrentWriteAttempts below) throw new NLogRuntimeException("Could not create directory {0}", directoryName); } - return TryCreateFileStream(allowFileSharedWriting); + return TryCreateFileStream(allowFileSharedWriting, overrideBufferSize); } } @@ -217,7 +218,7 @@ protected FileStream CreateFileStream(bool allowFileSharedWriting) #if !SILVERLIGHT && !MONO && !__IOS__ && !__ANDROID__ && !NETSTANDARD [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Objects are disposed elsewhere")] - private FileStream WindowsCreateFile(string fileName, bool allowFileSharedWriting) + private FileStream WindowsCreateFile(string fileName, bool allowFileSharedWriting, int overrideBufferSize) { int fileShare = Win32FileNativeMethods.FILE_SHARE_READ; @@ -250,7 +251,7 @@ private FileStream WindowsCreateFile(string fileName, bool allowFileSharedWritin Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } - fileStream = new FileStream(handle, FileAccess.Write, CreateFileParameters.BufferSize); + fileStream = new FileStream(handle, FileAccess.Write, overrideBufferSize > 0 ? overrideBufferSize : CreateFileParameters.BufferSize); fileStream.Seek(0, SeekOrigin.End); return fileStream; } @@ -266,7 +267,7 @@ private FileStream WindowsCreateFile(string fileName, bool allowFileSharedWritin } #endif - private FileStream TryCreateFileStream(bool allowFileSharedWriting) + private FileStream TryCreateFileStream(bool allowFileSharedWriting, int overrideBufferSize) { UpdateCreationTime(); @@ -275,7 +276,7 @@ private FileStream TryCreateFileStream(bool allowFileSharedWriting) { if (!CreateFileParameters.ForceManaged && PlatformDetector.IsWin32 && !PlatformDetector.IsMono) { - return WindowsCreateFile(FileName, allowFileSharedWriting); + return WindowsCreateFile(FileName, allowFileSharedWriting, overrideBufferSize); } } catch (SecurityException) @@ -295,7 +296,7 @@ private FileStream TryCreateFileStream(bool allowFileSharedWriting) FileMode.Append, FileAccess.Write, fileShare, - CreateFileParameters.BufferSize); + overrideBufferSize > 0 ? overrideBufferSize : CreateFileParameters.BufferSize); } private void UpdateCreationTime() diff --git a/src/NLog/Internal/FileAppenders/RetryingMultiProcessFileAppender.cs b/src/NLog/Internal/FileAppenders/RetryingMultiProcessFileAppender.cs index 750b59f918..b3360053b9 100644 --- a/src/NLog/Internal/FileAppenders/RetryingMultiProcessFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/RetryingMultiProcessFileAppender.cs @@ -63,7 +63,8 @@ public RetryingMultiProcessFileAppender(string fileName, ICreateFileParameters p /// The number of bytes. public override void Write(byte[] bytes, int offset, int count) { - using (FileStream fileStream = CreateFileStream(false)) + int overrideBufferSize = Math.Min((count / 4096 + 1) * 4096, CreateFileParameters.BufferSize); + using (FileStream fileStream = CreateFileStream(false, overrideBufferSize)) { fileStream.Write(bytes, offset, count); } From 05b6faffb0721de88af690f34906da8c61c8cdda Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Thu, 30 May 2019 21:02:18 +0200 Subject: [PATCH 02/15] Log4JXmlEventLayout - Added IncludeCallSite + IncludeSourceInfo (#3442) --- src/NLog/Layouts/Log4JXmlEventLayout.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/NLog/Layouts/Log4JXmlEventLayout.cs b/src/NLog/Layouts/Log4JXmlEventLayout.cs index 83c06b47e0..7e073ce52a 100644 --- a/src/NLog/Layouts/Log4JXmlEventLayout.cs +++ b/src/NLog/Layouts/Log4JXmlEventLayout.cs @@ -126,6 +126,26 @@ public bool IncludeNdlc } #endif + /// + /// Gets or sets a value indicating whether to include call site (class and method name) in the information sent over the network. + /// + /// + public bool IncludeCallSite + { + get => Renderer.IncludeCallSite; + set => Renderer.IncludeCallSite = value; + } + + /// + /// Gets or sets a value indicating whether to include source info (file name and line number) in the information sent over the network. + /// + /// + public bool IncludeSourceInfo + { + get => Renderer.IncludeSourceInfo; + set => Renderer.IncludeSourceInfo = value; + } + internal override void PrecalculateBuilder(LogEventInfo logEvent, StringBuilder target) { PrecalculateBuilderInternal(logEvent, target); From 46847fa216ac88afc5498b08f382d086ebc1b1c0 Mon Sep 17 00:00:00 2001 From: Kahath Date: Sun, 9 Jun 2019 09:58:48 +0200 Subject: [PATCH 03/15] Added null terminator line ending for network target (#3453) --- src/NLog/Targets/LineEndingMode.cs | 7 +++++++ tests/NLog.UnitTests/Targets/LineEndingModeTests.cs | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/NLog/Targets/LineEndingMode.cs b/src/NLog/Targets/LineEndingMode.cs index d7781fa705..9d8ac68d87 100644 --- a/src/NLog/Targets/LineEndingMode.cs +++ b/src/NLog/Targets/LineEndingMode.cs @@ -71,6 +71,12 @@ public sealed class LineEndingMode : IEquatable [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Type is immutable")] public static readonly LineEndingMode LF = new LineEndingMode("LF", "\n"); + /// + /// Insert null terminator (ASCII 0) after each line. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Type is immutable")] + public static readonly LineEndingMode Null = new LineEndingMode("Null", "\0"); + /// /// Do not insert any line ending. /// @@ -122,6 +128,7 @@ public static LineEndingMode FromString([NotNull] string name) if (name.Equals(LF.Name, StringComparison.OrdinalIgnoreCase)) return LF; if (name.Equals(CR.Name, StringComparison.OrdinalIgnoreCase)) return CR; if (name.Equals(Default.Name, StringComparison.OrdinalIgnoreCase)) return Default; + if (name.Equals(Null.Name, StringComparison.OrdinalIgnoreCase)) return Null; if (name.Equals(None.Name, StringComparison.OrdinalIgnoreCase)) return None; #if !SILVERLIGHT diff --git a/tests/NLog.UnitTests/Targets/LineEndingModeTests.cs b/tests/NLog.UnitTests/Targets/LineEndingModeTests.cs index 32c1bec8d3..ce36c67e7e 100644 --- a/tests/NLog.UnitTests/Targets/LineEndingModeTests.cs +++ b/tests/NLog.UnitTests/Targets/LineEndingModeTests.cs @@ -47,22 +47,27 @@ public void LineEndingModeEqualityTest() LineEndingMode modeNone = LineEndingMode.None; LineEndingMode modeLF = LineEndingMode.LF; LineEndingMode modeCRLF = LineEndingMode.CRLF; + LineEndingMode modeNull = LineEndingMode.Null; Assert.True(LineEndingMode.Default == modeDefault); Assert.True(LineEndingMode.None == modeNone); Assert.True(LineEndingMode.LF == modeLF); + Assert.True(LineEndingMode.Null == modeNull); Assert.False(LineEndingMode.Default == modeNone); Assert.False(LineEndingMode.None == modeLF); Assert.False(LineEndingMode.None == modeCRLF); + Assert.False(LineEndingMode.None == modeNull); Assert.False(LineEndingMode.None == (object)new { }); Assert.False(LineEndingMode.None == null); Assert.True(LineEndingMode.Default.Equals(modeDefault)); Assert.True(LineEndingMode.None.Equals(modeNone)); Assert.True(LineEndingMode.LF.Equals(modeLF)); + Assert.True(LineEndingMode.Null.Equals(modeNull)); Assert.False(LineEndingMode.Default.Equals(modeNone)); Assert.False(LineEndingMode.None.Equals(modeLF)); Assert.False(LineEndingMode.None.Equals(modeCRLF)); + Assert.False(LineEndingMode.None.Equals(modeNull)); Assert.False(LineEndingMode.None.Equals(new { })); Assert.False(LineEndingMode.None.Equals(null)); @@ -86,14 +91,17 @@ public void LineEndingModeInequalityTest() LineEndingMode modeNone = LineEndingMode.None; LineEndingMode modeLF = LineEndingMode.LF; LineEndingMode modeCRLF = LineEndingMode.CRLF; + LineEndingMode modeNull = LineEndingMode.Null; Assert.True(LineEndingMode.Default != modeNone); Assert.True(LineEndingMode.None != modeLF); Assert.True(LineEndingMode.None != modeCRLF); + Assert.True(LineEndingMode.None != modeNull); Assert.False(LineEndingMode.Default != modeDefault); Assert.False(LineEndingMode.None != modeNone); Assert.False(LineEndingMode.LF != modeLF); Assert.False(LineEndingMode.CRLF != modeCRLF); + Assert.False(LineEndingMode.Null != modeNull); Assert.True(null != LineEndingMode.LF); Assert.True(null != modeLF); @@ -103,6 +111,10 @@ public void LineEndingModeInequalityTest() Assert.True(null != modeCRLF); Assert.True(LineEndingMode.CRLF != null); Assert.True(modeCRLF != null); + Assert.True(null != LineEndingMode.Null); + Assert.True(null != modeNull); + Assert.True(LineEndingMode.Null != null); + Assert.True(modeNull != null); // Handle running tests on different operating systems if (modeCRLF.NewLineCharacters == Environment.NewLine) @@ -139,6 +151,7 @@ public void LineEndingModeToStringTest() Assert.Equal("CRLF", LineEndingMode.CRLF.ToString()); Assert.Equal("CR", LineEndingMode.CR.ToString()); Assert.Equal("LF", LineEndingMode.LF.ToString()); + Assert.Equal("Null", LineEndingMode.Null.ToString()); } } } From 00709be22a81f54773e74f5fc59ef1e239907172 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Wed, 12 Jun 2019 17:53:27 +0200 Subject: [PATCH 04/15] Added testcase for with inner (#3471) --- tests/NLog.UnitTests/Config/VariableTests.cs | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/NLog.UnitTests/Config/VariableTests.cs b/tests/NLog.UnitTests/Config/VariableTests.cs index 5853ce4291..eae96727c4 100644 --- a/tests/NLog.UnitTests/Config/VariableTests.cs +++ b/tests/NLog.UnitTests/Config/VariableTests.cs @@ -157,6 +157,29 @@ public void Xml_configuration_returns_defined_variables() Assert.Equal("]]", LogManager.Configuration.Variables["suffix"].OriginalText); } + [Fact] + public void Xml_configuration_with_inner_returns_defined_variables_withValueElement() + { + var configuration = XmlLoggingConfiguration.CreateFromXmlString(@" + + + + + + + ]] +"); + + var nullEvent = LogEventInfo.CreateNullEvent(); + + // Act & Assert + Assert.Equal("\nnewline\n", configuration.Variables["prefix"].Render(nullEvent).Replace("\r", "")); + Assert.Equal("]]", configuration.Variables["suffix"].Render(nullEvent)); + } + + [Fact] public void NLogConfigurationExceptionShouldThrown_WhenVariableNodeIsWrittenToWrongPlace() { From a2386379ec51d67510cffe442e1a96c3b39d131e Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Thu, 13 Jun 2019 00:10:55 +0200 Subject: [PATCH 05/15] AppSettingLayoutRenderer2 - Added support for ConnectionStrings Lookup (#3477) --- src/NLog/Internal/ConfigurationManager2.cs | 51 +++++++++++++++++++ src/NLog/Internal/IConfigurationManager2.cs | 44 ++++++++++++++++ .../AppSettingLayoutRenderer2.cs | 16 +++++- .../LayoutRenderers/AppSettingTests.cs | 34 ++++++++++--- 4 files changed, 137 insertions(+), 8 deletions(-) create mode 100644 src/NLog/Internal/ConfigurationManager2.cs create mode 100644 src/NLog/Internal/IConfigurationManager2.cs diff --git a/src/NLog/Internal/ConfigurationManager2.cs b/src/NLog/Internal/ConfigurationManager2.cs new file mode 100644 index 0000000000..da860fa66c --- /dev/null +++ b/src/NLog/Internal/ConfigurationManager2.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) 2004-2019 Jaroslaw Kowalski , Kim Christensen, Julian Verdurmen +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of Jaroslaw Kowalski nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +// THE POSSIBILITY OF SUCH DAMAGE. +// + +#if !SILVERLIGHT && !__IOS__ && !__ANDROID__ && !NETSTANDARD + +namespace NLog.Internal +{ + using System.Collections.Specialized; + + internal class ConfigurationManager2 : IConfigurationManager2 + { + public System.Configuration.ConnectionStringSettings LookupConnectionString(string name) + { + return System.Configuration.ConfigurationManager.ConnectionStrings[name]; + } + + public NameValueCollection AppSettings => System.Configuration.ConfigurationManager.AppSettings; + } +} + +#endif \ No newline at end of file diff --git a/src/NLog/Internal/IConfigurationManager2.cs b/src/NLog/Internal/IConfigurationManager2.cs new file mode 100644 index 0000000000..c999655125 --- /dev/null +++ b/src/NLog/Internal/IConfigurationManager2.cs @@ -0,0 +1,44 @@ +// +// Copyright (c) 2004-2019 Jaroslaw Kowalski , Kim Christensen, Julian Verdurmen +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of Jaroslaw Kowalski nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +// THE POSSIBILITY OF SUCH DAMAGE. +// + +#if !SILVERLIGHT && !__IOS__ && !__ANDROID__ && !NETSTANDARD + +namespace NLog.Internal +{ + internal interface IConfigurationManager2 : IConfigurationManager + { + System.Configuration.ConnectionStringSettings LookupConnectionString(string name); + } +} + +#endif \ No newline at end of file diff --git a/src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs b/src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs index 3b96b97709..645ffc5b10 100644 --- a/src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs +++ b/src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs @@ -55,6 +55,8 @@ namespace NLog.LayoutRenderers [ThreadSafe] public sealed class AppSettingLayoutRenderer2 : LayoutRenderer, IStringValueRenderer { + private string _connectionStringName = null; + /// /// The AppSetting item-name /// @@ -75,7 +77,15 @@ public sealed class AppSettingLayoutRenderer2 : LayoutRenderer, IStringValueRend /// public string Default { get; set; } - internal IConfigurationManager ConfigurationManager { get; set; } = new ConfigurationManager(); + internal IConfigurationManager2 ConfigurationManager { get; set; } = new ConfigurationManager2(); + + /// + protected override void InitializeLayoutRenderer() + { + string connectionStringSection = "ConnectionStrings."; + _connectionStringName = Item?.TrimStart().StartsWith(connectionStringSection, StringComparison.InvariantCultureIgnoreCase) == true ? + Item.TrimStart().Substring(connectionStringSection.Length) : null; + } /// /// Renders the specified application setting or default value and appends it to the specified . @@ -94,7 +104,9 @@ private string GetStringValue() if (string.IsNullOrEmpty(Item)) return Default; - string value = ConfigurationManager.AppSettings[Item]; + string value = _connectionStringName != null ? + ConfigurationManager.LookupConnectionString(_connectionStringName)?.ConnectionString : + ConfigurationManager.AppSettings[Item]; if (value == null && Default != null) value = Default; diff --git a/tests/NLog.UnitTests/LayoutRenderers/AppSettingTests.cs b/tests/NLog.UnitTests/LayoutRenderers/AppSettingTests.cs index f15f32e36c..395d2d6f0c 100644 --- a/tests/NLog.UnitTests/LayoutRenderers/AppSettingTests.cs +++ b/tests/NLog.UnitTests/LayoutRenderers/AppSettingTests.cs @@ -35,10 +35,12 @@ namespace NLog.UnitTests.LayoutRenderers { + using System.Collections.Generic; using System.Collections.Specialized; + using System.Configuration; using NLog.Internal; using NLog.LayoutRenderers; - using Xunit; + using Xunit; public class AppSettingTests : NLogTestBase { @@ -109,14 +111,34 @@ public void NoAppSettingTest() Assert.Equal(string.Empty, rendered); } - private class MockConfigurationManager : IConfigurationManager + [Fact] + public void UseConnectionStringTest() { - public MockConfigurationManager() + var configurationManager = new MockConfigurationManager(); + const string expected = "Hello Connection"; + configurationManager.ConnectionStrings["myConnection"] = new ConnectionStringSettings() { ConnectionString = expected }; + var appSettingLayoutRenderer = new AppSettingLayoutRenderer2 { - AppSettings = new NameValueCollection(); - } + ConfigurationManager = configurationManager, + Item = "ConnectionStrings.myConnection", + }; + + var rendered = appSettingLayoutRenderer.Render(LogEventInfo.CreateNullEvent()); - public NameValueCollection AppSettings { get; private set; } + Assert.Equal(expected, rendered); + } + + private class MockConfigurationManager : IConfigurationManager2 + { + public NameValueCollection AppSettings { get; } = new NameValueCollection(); + + public Dictionary ConnectionStrings { get; } = new Dictionary(); + + public ConnectionStringSettings LookupConnectionString(string name) + { + ConnectionStrings.TryGetValue(name, out var value); + return value; + } } } } From d85b7f5e8732e6f36cfb91db6f1b62699ad95b04 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Thu, 13 Jun 2019 02:04:13 +0200 Subject: [PATCH 06/15] Added test: with attr and (#3479) --- tests/NLog.UnitTests/Config/VariableTests.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/NLog.UnitTests/Config/VariableTests.cs b/tests/NLog.UnitTests/Config/VariableTests.cs index eae96727c4..fddb04eb6a 100644 --- a/tests/NLog.UnitTests/Config/VariableTests.cs +++ b/tests/NLog.UnitTests/Config/VariableTests.cs @@ -179,6 +179,19 @@ public void Xml_configuration_with_inner_returns_defined_variables_withValueElem Assert.Equal("]]", configuration.Variables["suffix"].Render(nullEvent)); } + [Fact] + public void Xml_configuration_variableWithInnerAndAttribute_attributeHasPrecedence() + { + var configuration = XmlLoggingConfiguration.CreateFromXmlString(@" + + 2 +"); + + var nullEvent = LogEventInfo.CreateNullEvent(); + + // Act & Assert + Assert.Equal("1", configuration.Variables["var1"].FixedText); + } [Fact] public void NLogConfigurationExceptionShouldThrown_WhenVariableNodeIsWrittenToWrongPlace() From 75afe1adc3995049628c5b22c59f66b71f1c4002 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Thu, 13 Jun 2019 02:36:53 +0200 Subject: [PATCH 07/15] XSD: Support in (#3478) * Support value in variable --- tools/MakeNLogXSD/TemplateXSD.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/MakeNLogXSD/TemplateXSD.xml b/tools/MakeNLogXSD/TemplateXSD.xml index 713dc6dfa0..454f527d81 100644 --- a/tools/MakeNLogXSD/TemplateXSD.xml +++ b/tools/MakeNLogXSD/TemplateXSD.xml @@ -234,12 +234,19 @@ + + + + Variable value. Note, the 'value' attribute has precedence over this one. + + + Variable name. - + Variable value. From 218961f5ac53c825e4bcb21272ef92a38df0433f Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Thu, 13 Jun 2019 03:10:33 +0200 Subject: [PATCH 08/15] FilteringTargetWrapper - Fix XSD for Filter-property (#3476) * FilteringTargetWrapper - Fix XSD for Filter-property * FilteringTargetWrapper - Fix XSD for Filter-property (never as attribute) * FilteringTargetWrapper - Updated unit-test to fail when adding unwanted attribute * Added tests --- .../Wrappers/FilteringTargetWrapperTests.cs | 58 ++++++++++++++++++- tools/MakeNLogXSD/XsdFileGenerator.cs | 30 +++++----- 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/tests/NLog.UnitTests/Targets/Wrappers/FilteringTargetWrapperTests.cs b/tests/NLog.UnitTests/Targets/Wrappers/FilteringTargetWrapperTests.cs index ec36acf28f..5931bf1184 100644 --- a/tests/NLog.UnitTests/Targets/Wrappers/FilteringTargetWrapperTests.cs +++ b/tests/NLog.UnitTests/Targets/Wrappers/FilteringTargetWrapperTests.cs @@ -31,6 +31,8 @@ // THE POSSIBILITY OF SUCH DAMAGE. // +using NLog.Filters; + namespace NLog.UnitTests.Targets.Wrappers { using System; @@ -43,7 +45,7 @@ namespace NLog.UnitTests.Targets.Wrappers using Xunit; public class FilteringTargetWrapperTests : NLogTestBase - { + { [Fact] public void FilteringTargetWrapperSyncTest1() { @@ -273,10 +275,11 @@ public void FilteringTargetWrapperWhenRepeatedFilter() { LogManager.Configuration = XmlLoggingConfiguration.CreateFromXmlString(@" + - + @@ -301,6 +304,57 @@ public void FilteringTargetWrapperWhenRepeatedFilter() Assert.Equal(5, myTarget.Logs.Count); } + [Fact] + public void FilteringTargetWrapperWithConditionAttribute_correctBehavior() + { + // Arrange + LogManager.Configuration = CreateConfigWithCondition(); + var myTarget = LogManager.Configuration.FindTargetByName("memory"); + + // Act + var logger = LogManager.GetLogger(nameof(FilteringTargetWrapperWhenRepeatedFilter)); + logger.Info("Hello World"); + logger.Info("2"); // Will be ignored + logger.Info("3"); // Will be ignored + LogManager.Flush(); + + // Assert + Assert.Equal(1, myTarget.Logs.Count); + } + + [Fact] + public void FilteringTargetWrapperWithConditionAttribute_validCondition() + { + // Arrange + var expectedCondition = "(length(message) > 2)"; + + // Act + var config = CreateConfigWithCondition(); + + // Assert + var myTarget = config.FindTargetByName("target1"); + + Assert.Equal(expectedCondition, myTarget.Condition?.ToString()); + var conditionBasedFilter = Assert.IsType(myTarget.Filter); + Assert.Equal(expectedCondition, conditionBasedFilter.Condition?.ToString()); + } + + private static XmlLoggingConfiguration CreateConfigWithCondition() + { + return XmlLoggingConfiguration.CreateFromXmlString(@" + + + + + + + + + + "); + } + + class MyAsyncTarget : Target { public int WriteCount { get; private set; } diff --git a/tools/MakeNLogXSD/XsdFileGenerator.cs b/tools/MakeNLogXSD/XsdFileGenerator.cs index f9069e47e5..fbef5ebf03 100644 --- a/tools/MakeNLogXSD/XsdFileGenerator.cs +++ b/tools/MakeNLogXSD/XsdFileGenerator.cs @@ -206,13 +206,13 @@ private static XElement GetAttributeElement(XElement propertyElement) result.Add(new XAttribute("type", enumType)); } - else if (IgnoreTypes.Contains(propertyType)) + else { - return null; - } - else - { - result.Add(new XAttribute("type", GetXsdType(propertyType, true))); + string xsdType = GetXsdType(propertyType, false); + if (xsdType == null) + return null; + + result.Add(new XAttribute("type", xsdType)); } var doc = propertyElement.Element("doc"); @@ -284,14 +284,14 @@ private static XElement GetPropertyElement(XElement propertyElement) result.Add(new XAttribute("maxOccurs", "1")); result.Add(new XAttribute("type", enumType)); } - else if (IgnoreTypes.Contains(propertyType)) - { - return null; - } else { + string xsdType = GetXsdType(propertyType, false); + if (xsdType == null) + return null; + result.Add(new XAttribute("maxOccurs", "1")); - result.Add(new XAttribute("type", GetXsdType(propertyType, false))); + result.Add(new XAttribute("type", xsdType)); } return result; @@ -301,19 +301,23 @@ private static XElement GetPropertyElement(XElement propertyElement) private static string GetXsdType(string apiTypeName, bool attribute) { - if (string.IsNullOrWhiteSpace(apiTypeName)) { throw new NotSupportedException("Unknown API type '" + apiTypeName + "'."); } + if (IgnoreTypes.Contains(apiTypeName)) + { + return null; + } + switch (apiTypeName) { case "Layout": return attribute ? "SimpleLayoutAttribute" : "Layout"; case "NLog.Filters.Filter": - return "Filter"; + return attribute ? null : "Filter"; case "Condition": return "Condition"; From 6c8a16f8848351f624a4edba7662a9dbdf4df887 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Thu, 13 Jun 2019 12:10:55 +0200 Subject: [PATCH 09/15] Fix typos in docs (#3482) --- src/NLog/Config/ConfigurationItemFactory.cs | 2 +- src/NLog/Layouts/JsonAttribute.cs | 2 +- src/NLog/Layouts/XmlAttribute.cs | 2 +- src/NLog/Layouts/XmlElement.cs | 2 +- src/NLog/Layouts/XmlLayout.cs | 2 +- src/NLog/MessageTemplates/Template.cs | 2 +- src/NLog/Targets/DatabaseParameterInfo.cs | 2 +- src/NLog/Targets/FileTarget.cs | 2 +- src/NLog/Targets/NLogViewerParameterInfo.cs | 2 +- src/NLog/Targets/NetworkTargetConnectionsOverflowAction.cs | 2 +- tools/MakeNLogXSD/TemplateXSD.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/NLog/Config/ConfigurationItemFactory.cs b/src/NLog/Config/ConfigurationItemFactory.cs index a9322b78b0..202cd79bbc 100644 --- a/src/NLog/Config/ConfigurationItemFactory.cs +++ b/src/NLog/Config/ConfigurationItemFactory.cs @@ -199,7 +199,7 @@ public IValueFormatter ValueFormatter public IPropertyTypeConverter PropertyTypeConverter { get; set; } = new PropertyTypeConverter(); /// - /// Perform mesage template parsing and formatting of LogEvent messages (True = Always, False = Never, Null = Auto Detect) + /// Perform message template parsing and formatting of LogEvent messages (True = Always, False = Never, Null = Auto Detect) /// /// /// - Null (Auto Detect) : NLog-parser checks for positional parameters, and will then fallback to string.Format-rendering. diff --git a/src/NLog/Layouts/JsonAttribute.cs b/src/NLog/Layouts/JsonAttribute.cs index 599587eef4..c6da83d9ca 100644 --- a/src/NLog/Layouts/JsonAttribute.cs +++ b/src/NLog/Layouts/JsonAttribute.cs @@ -89,7 +89,7 @@ public Layout Layout } /// - /// Determines wether or not this attribute will be Json encoded. + /// Determines whether or not this attribute will be Json encoded. /// /// public bool Encode diff --git a/src/NLog/Layouts/XmlAttribute.cs b/src/NLog/Layouts/XmlAttribute.cs index b4d629510d..64b3a72ee3 100644 --- a/src/NLog/Layouts/XmlAttribute.cs +++ b/src/NLog/Layouts/XmlAttribute.cs @@ -93,7 +93,7 @@ public Layout Layout } /// - /// Determines wether or not this attribute will be Xml encoded. + /// Determines whether or not this attribute will be Xml encoded. /// /// [DefaultValue(true)] diff --git a/src/NLog/Layouts/XmlElement.cs b/src/NLog/Layouts/XmlElement.cs index cb2fbeb533..1b80802b7a 100644 --- a/src/NLog/Layouts/XmlElement.cs +++ b/src/NLog/Layouts/XmlElement.cs @@ -77,7 +77,7 @@ public Layout Value } /// - /// Determines wether or not this attribute will be Xml encoded. + /// Determines whether or not this attribute will be Xml encoded. /// [DefaultValue(true)] public bool Encode diff --git a/src/NLog/Layouts/XmlLayout.cs b/src/NLog/Layouts/XmlLayout.cs index 771f84a238..b0b9093d93 100644 --- a/src/NLog/Layouts/XmlLayout.cs +++ b/src/NLog/Layouts/XmlLayout.cs @@ -82,7 +82,7 @@ public Layout ElementValue } /// - /// Determines wether or not this attribute will be Xml encoded. + /// Determines whether or not this attribute will be Xml encoded. /// /// [DefaultValue(true)] diff --git a/src/NLog/MessageTemplates/Template.cs b/src/NLog/MessageTemplates/Template.cs index 9eb6637a2f..73048c8869 100644 --- a/src/NLog/MessageTemplates/Template.cs +++ b/src/NLog/MessageTemplates/Template.cs @@ -38,7 +38,7 @@ namespace NLog.MessageTemplates { /// - /// A mesage template + /// A message template /// internal class Template { diff --git a/src/NLog/Targets/DatabaseParameterInfo.cs b/src/NLog/Targets/DatabaseParameterInfo.cs index 155b30f358..486e178cf4 100644 --- a/src/NLog/Targets/DatabaseParameterInfo.cs +++ b/src/NLog/Targets/DatabaseParameterInfo.cs @@ -78,7 +78,7 @@ public DatabaseParameterInfo(string parameterName, Layout parameterLayout) public string Name { get; set; } /// - /// Gets or sets the layout that should be use to calcuate the value for the parameter. + /// Gets or sets the layout that should be use to calculate the value for the parameter. /// /// [RequiredParameter] diff --git a/src/NLog/Targets/FileTarget.cs b/src/NLog/Targets/FileTarget.cs index 4e1a371700..3326bc18ab 100644 --- a/src/NLog/Targets/FileTarget.cs +++ b/src/NLog/Targets/FileTarget.cs @@ -709,7 +709,7 @@ public bool EnableArchiveFileCompression #if SupportsMutex /// - /// Gets or sets a value indicationg whether file creation calls should be synchronized by a system global mutex. + /// Gets or sets a value indicating whether file creation calls should be synchronized by a system global mutex. /// /// [DefaultValue(false)] diff --git a/src/NLog/Targets/NLogViewerParameterInfo.cs b/src/NLog/Targets/NLogViewerParameterInfo.cs index d4a5fe1335..fb82df55eb 100644 --- a/src/NLog/Targets/NLogViewerParameterInfo.cs +++ b/src/NLog/Targets/NLogViewerParameterInfo.cs @@ -60,7 +60,7 @@ public NLogViewerParameterInfo() public string Name { get; set; } /// - /// Gets or sets the layout that should be use to calcuate the value for the parameter. + /// Gets or sets the layout that should be use to calculate the value for the parameter. /// /// [RequiredParameter] diff --git a/src/NLog/Targets/NetworkTargetConnectionsOverflowAction.cs b/src/NLog/Targets/NetworkTargetConnectionsOverflowAction.cs index 249753f396..32228481fc 100644 --- a/src/NLog/Targets/NetworkTargetConnectionsOverflowAction.cs +++ b/src/NLog/Targets/NetworkTargetConnectionsOverflowAction.cs @@ -45,7 +45,7 @@ public enum NetworkTargetConnectionsOverflowAction /// /// Just allow it. /// - AllowNewConnnection, + AllowNewConnnection, //TODO Nlog 5 - fix typo and obsolete this one /// /// Discard the connection item. diff --git a/tools/MakeNLogXSD/TemplateXSD.xml b/tools/MakeNLogXSD/TemplateXSD.xml index 454f527d81..661b02f024 100644 --- a/tools/MakeNLogXSD/TemplateXSD.xml +++ b/tools/MakeNLogXSD/TemplateXSD.xml @@ -78,7 +78,7 @@ - Perform mesage template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. + Perform message template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. From c0175fc902214de112ae28eb978f367180059348 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Thu, 13 Jun 2019 12:12:50 +0200 Subject: [PATCH 10/15] Fix typos in comments and test code (#3483) --- src/NLog.sln.DotSettings | 8 +++- src/NLog/Annotations.cs | 2 +- src/NLog/Common/InternalLogger.cs | 2 +- .../ConditionRelationalExpression.cs | 2 +- src/NLog/Config/ConfigurationItemFactory.cs | 2 +- src/NLog/Config/ExceptionRenderingFormat.cs | 2 +- src/NLog/Config/Factory.cs | 2 +- src/NLog/Config/LoggerNameMatcher.cs | 2 +- src/NLog/Config/XmlLoggingConfiguration.cs | 4 +- .../FileAppenders/BaseFileAppender.cs | 4 +- .../CountingSingleProcessFileAppender.cs | 2 +- .../FileAppenders/FileAppenderCache.cs | 2 +- .../MutexMultiProcessFileAppender.cs | 2 +- .../RetryingMultiProcessFileAppender.cs | 2 +- .../SingleProcessFileAppender.cs | 2 +- .../UnixMultiProcessFileAppender.cs | 2 +- .../WindowsMultiProcessFileAppender.cs | 2 +- src/NLog/Internal/LayoutHelpers-generated.cs | 4 +- .../NetworkSenders/HttpNetworkSender.cs | 2 +- src/NLog/Internal/StringBuilderExt.cs | 2 +- src/NLog/Internal/XmlHelper.cs | 2 +- src/NLog/LayoutRenderers/LayoutRenderer.cs | 4 +- .../LayoutRenderers/RegistryLayoutRenderer.cs | 2 +- .../XmlEncodeLayoutRendererWrapper.cs | 2 +- src/NLog/Layouts/Layout.cs | 8 ++-- src/NLog/Layouts/LayoutParser.cs | 2 +- src/NLog/LogManager.cs | 2 +- src/NLog/MessageTemplates/ValueFormatter.cs | 2 +- src/NLog/Targets/AsyncTaskTarget.cs | 4 +- src/NLog/Targets/DefaultJsonSerializer.cs | 6 +-- src/NLog/Targets/FileTarget.cs | 12 ++--- src/NLog/Targets/JsonSerializeOptions.cs | 2 +- src/NLog/Targets/MailTarget.cs | 2 +- src/NLog/Targets/Target.cs | 4 +- src/NLog/Targets/WebServiceTarget.cs | 2 +- .../Targets/Wrappers/AsyncTargetWrapper.cs | 2 +- .../Wrappers/AutoFlushTargetWrapper.cs | 2 +- .../Conditions/ConditionEvaluatorTests.cs | 4 +- tests/NLog.UnitTests/Config/ExtensionTests.cs | 12 ++--- .../FileAppenders/FileAppenderCacheTests.cs | 2 +- .../Internal/LayoutHelpersTests.cs | 2 +- .../LayoutRenderers/ExceptionTests.cs | 2 +- .../Layouts/SimpleLayoutParserTests.cs | 2 +- .../LogReceiverServiceTests.cs | 22 +++++----- tests/NLog.UnitTests/LoggerTests.cs | 4 +- .../Targets/ColoredConsoleTargetTests.cs | 2 +- .../Targets/ConcurrentFileTargetTests.cs | 22 +++++----- .../NLog.UnitTests/Targets/FileTargetTests.cs | 8 ++-- .../Targets/WebServiceTargetTests.cs | 44 +++++++++---------- .../Wrappers/LimitingTargetWrapperTests.cs | 2 +- 50 files changed, 123 insertions(+), 117 deletions(-) diff --git a/src/NLog.sln.DotSettings b/src/NLog.sln.DotSettings index 059ce044ac..7799226a3d 100644 --- a/src/NLog.sln.DotSettings +++ b/src/NLog.sln.DotSettings @@ -7,4 +7,10 @@ DO_NOT_SHOW EOF GDC - MDC \ No newline at end of file + MDC + True + True + True + True + True + True \ No newline at end of file diff --git a/src/NLog/Annotations.cs b/src/NLog/Annotations.cs index 62552e7eba..03807640d7 100644 --- a/src/NLog/Annotations.cs +++ b/src/NLog/Annotations.cs @@ -208,7 +208,7 @@ public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) /// /// If method has single input parameter, it's name could be omitted.
/// Using halt (or void/nothing, which is the same) for method output - /// means that the methos doesn't return normally (throws or terminates the process).
+ /// means that the methods doesn't return normally (throws or terminates the process).
/// Value canbenull is only applicable for output parameters.
/// You can use multiple [ContractAnnotation] for each FDT row, or use single attribute /// with rows separated by semicolon. There is no notion of order rows, all rows are checked diff --git a/src/NLog/Common/InternalLogger.cs b/src/NLog/Common/InternalLogger.cs index d0e85fda10..809c6500b9 100644 --- a/src/NLog/Common/InternalLogger.cs +++ b/src/NLog/Common/InternalLogger.cs @@ -452,7 +452,7 @@ private static void WriteToErrorConsole(string message) /// A message to write. /// /// Works when property set to true. - /// The is used in Debug and Relese configuration. + /// The is used in Debug and Relaese configuration. /// The works only in Debug configuration and this is reason why is replaced by . /// in DEBUG /// diff --git a/src/NLog/Conditions/ConditionRelationalExpression.cs b/src/NLog/Conditions/ConditionRelationalExpression.cs index 32eea0631a..c6dcf02b90 100644 --- a/src/NLog/Conditions/ConditionRelationalExpression.cs +++ b/src/NLog/Conditions/ConditionRelationalExpression.cs @@ -177,7 +177,7 @@ private static void PromoteTypes(ref object leftValue, ref object rightValue) } /// - /// Promoto to type + /// Promotes to type /// /// /// diff --git a/src/NLog/Config/ConfigurationItemFactory.cs b/src/NLog/Config/ConfigurationItemFactory.cs index 202cd79bbc..dcd2b87e17 100644 --- a/src/NLog/Config/ConfigurationItemFactory.cs +++ b/src/NLog/Config/ConfigurationItemFactory.cs @@ -317,7 +317,7 @@ private void CallPreload(Type type) var parameters = CreatePreloadParameters(preloadMethod, this); preloadMethod.Invoke(null, parameters); - InternalLogger.Debug("Preload succesfully invoked for '{0}'", type.FullName); + InternalLogger.Debug("Preload successfully invoked for '{0}'", type.FullName); } catch (Exception e) { diff --git a/src/NLog/Config/ExceptionRenderingFormat.cs b/src/NLog/Config/ExceptionRenderingFormat.cs index 9776db2e36..5f208da604 100644 --- a/src/NLog/Config/ExceptionRenderingFormat.cs +++ b/src/NLog/Config/ExceptionRenderingFormat.cs @@ -34,7 +34,7 @@ namespace NLog.Config { /// - /// Format of the excpetion output to the specific target. + /// Format of the exception output to the specific target. /// public enum ExceptionRenderingFormat { diff --git a/src/NLog/Config/Factory.cs b/src/NLog/Config/Factory.cs index ac1d1e23bb..2d8d04bd31 100644 --- a/src/NLog/Config/Factory.cs +++ b/src/NLog/Config/Factory.cs @@ -249,7 +249,7 @@ public void RegisterFuncLayout(string name, FuncLayoutRenderer renderer) /// True if instance was created successfully, false otherwise. public override bool TryCreateInstance(string itemName, out LayoutRenderer result) { - //first try func renderers, as they should have the possiblity to overwrite a current one. + //first try func renderers, as they should have the possibility to overwrite a current one. if (_funcRenderers != null) { FuncLayoutRenderer funcResult; diff --git a/src/NLog/Config/LoggerNameMatcher.cs b/src/NLog/Config/LoggerNameMatcher.cs index e84ada3b1e..dfc1a81fa8 100644 --- a/src/NLog/Config/LoggerNameMatcher.cs +++ b/src/NLog/Config/LoggerNameMatcher.cs @@ -236,7 +236,7 @@ public override bool NameMatches(string loggerName) /// /// Defines a that matches with a complex wildcards combinations: /// - /// '*' means zero or more occurrecnces of any character + /// '*' means zero or more occurrences of any character /// '?' means exactly one occurrence of any character /// /// used when pattern is a string containing any number of '?' or '*' in any position diff --git a/src/NLog/Config/XmlLoggingConfiguration.cs b/src/NLog/Config/XmlLoggingConfiguration.cs index 719a989854..a14a292252 100644 --- a/src/NLog/Config/XmlLoggingConfiguration.cs +++ b/src/NLog/Config/XmlLoggingConfiguration.cs @@ -125,7 +125,7 @@ private static XmlReader CreateFileReader(string fileName) { fileName = fileName.Trim(); #if __ANDROID__ - //suport loading config from special assets folder in nlog.config + //support loading config from special assets folder in nlog.config if (fileName.StartsWith(AssetsPrefix, StringComparison.OrdinalIgnoreCase)) { //remove prefix @@ -597,7 +597,7 @@ private void ConfigureFromFilesByMask(string baseDirectory, string fileMask, boo #endif foreach (var file in files) { - //note we exclude ourself in ConfigureFromFile + //note we exclude our self in ConfigureFromFile ConfigureFromFile(file, autoReloadDefault); } } diff --git a/src/NLog/Internal/FileAppenders/BaseFileAppender.cs b/src/NLog/Internal/FileAppenders/BaseFileAppender.cs index 0bd10c1e08..42e400e81f 100644 --- a/src/NLog/Internal/FileAppenders/BaseFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/BaseFileAppender.cs @@ -92,7 +92,7 @@ internal set public DateTime CreationTimeSource { get; private set; } /// - /// Gets the last time the file associated with the appeander is opened. The time returned is in Coordinated + /// Gets the last time the file associated with the appender is opened. The time returned is in Coordinated /// Universal Time [UTC] standard. /// /// The time the file was last opened. @@ -133,7 +133,7 @@ public void Write(byte[] bytes) public abstract DateTime? GetFileCreationTimeUtc(); /// - /// Gets the length in bytes of the file associated with the appeander. + /// Gets the length in bytes of the file associated with the appender. /// /// A long value representing the length of the file in bytes. public abstract long? GetFileLength(); diff --git a/src/NLog/Internal/FileAppenders/CountingSingleProcessFileAppender.cs b/src/NLog/Internal/FileAppenders/CountingSingleProcessFileAppender.cs index b46f55b760..b4c5fcb97b 100644 --- a/src/NLog/Internal/FileAppenders/CountingSingleProcessFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/CountingSingleProcessFileAppender.cs @@ -117,7 +117,7 @@ public override void Flush() } /// - /// Gets the length in bytes of the file associated with the appeander. + /// Gets the length in bytes of the file associated with the appender. /// /// A long value representing the length of the file in bytes. public override long? GetFileLength() diff --git a/src/NLog/Internal/FileAppenders/FileAppenderCache.cs b/src/NLog/Internal/FileAppenders/FileAppenderCache.cs index 8b8e42735c..fb0505ab36 100644 --- a/src/NLog/Internal/FileAppenders/FileAppenderCache.cs +++ b/src/NLog/Internal/FileAppenders/FileAppenderCache.cs @@ -339,7 +339,7 @@ public void CloseAppenders(string reason) } /// - /// Close the allocated appenders initialised before the supplied time. + /// Close the allocated appenders initialized before the supplied time. /// /// The time which prior the appenders considered expired public void CloseAppenders(DateTime expireTime) diff --git a/src/NLog/Internal/FileAppenders/MutexMultiProcessFileAppender.cs b/src/NLog/Internal/FileAppenders/MutexMultiProcessFileAppender.cs index 2bbd143ce0..1cdba25f86 100644 --- a/src/NLog/Internal/FileAppenders/MutexMultiProcessFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/MutexMultiProcessFileAppender.cs @@ -193,7 +193,7 @@ public override void Flush() } /// - /// Gets the length in bytes of the file associated with the appeander. + /// Gets the length in bytes of the file associated with the appender. /// /// A long value representing the length of the file in bytes. public override long? GetFileLength() diff --git a/src/NLog/Internal/FileAppenders/RetryingMultiProcessFileAppender.cs b/src/NLog/Internal/FileAppenders/RetryingMultiProcessFileAppender.cs index b3360053b9..a6ec465962 100644 --- a/src/NLog/Internal/FileAppenders/RetryingMultiProcessFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/RetryingMultiProcessFileAppender.cs @@ -102,7 +102,7 @@ public override void Close() } /// - /// Gets the length in bytes of the file associated with the appeander. + /// Gets the length in bytes of the file associated with the appender. /// /// A long value representing the length of the file in bytes. public override long? GetFileLength() diff --git a/src/NLog/Internal/FileAppenders/SingleProcessFileAppender.cs b/src/NLog/Internal/FileAppenders/SingleProcessFileAppender.cs index d366227741..4a33d86869 100644 --- a/src/NLog/Internal/FileAppenders/SingleProcessFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/SingleProcessFileAppender.cs @@ -137,7 +137,7 @@ public override void Close() } /// - /// Gets the length in bytes of the file associated with the appeander. + /// Gets the length in bytes of the file associated with the appender. /// /// A long value representing the length of the file in bytes. public override long? GetFileLength() diff --git a/src/NLog/Internal/FileAppenders/UnixMultiProcessFileAppender.cs b/src/NLog/Internal/FileAppenders/UnixMultiProcessFileAppender.cs index 6acebe8711..d1a5b9581c 100644 --- a/src/NLog/Internal/FileAppenders/UnixMultiProcessFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/UnixMultiProcessFileAppender.cs @@ -183,7 +183,7 @@ public override void Close() } /// - /// Gets the length in bytes of the file associated with the appeander. + /// Gets the length in bytes of the file associated with the appender. /// /// A long value representing the length of the file in bytes. public override long? GetFileLength() diff --git a/src/NLog/Internal/FileAppenders/WindowsMultiProcessFileAppender.cs b/src/NLog/Internal/FileAppenders/WindowsMultiProcessFileAppender.cs index 26c92cb982..8eb09eb695 100644 --- a/src/NLog/Internal/FileAppenders/WindowsMultiProcessFileAppender.cs +++ b/src/NLog/Internal/FileAppenders/WindowsMultiProcessFileAppender.cs @@ -204,7 +204,7 @@ public override void Flush() } /// - /// Gets the length in bytes of the file associated with the appeander. + /// Gets the length in bytes of the file associated with the appender. /// /// A long value representing the length of the file in bytes. public override long? GetFileLength() diff --git a/src/NLog/Internal/LayoutHelpers-generated.cs b/src/NLog/Internal/LayoutHelpers-generated.cs index 853848eece..d1c0b4d7d9 100644 --- a/src/NLog/Internal/LayoutHelpers-generated.cs +++ b/src/NLog/Internal/LayoutHelpers-generated.cs @@ -67,7 +67,7 @@ public static short RenderShort(this Layout layout, LogEventInfo logEvent, short short result; // NumberStyles.Integer is default of Convert.ToInt16 - // CultureInfo.InvariantCulture is backwardscomp. + // CultureInfo.InvariantCulture is backwards-compatible. if (!short.TryParse(rendered, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) { InternalLogger.Warn(layoutName + ": parse of value '" + rendered + "' failed, return " + defaultValue); @@ -101,7 +101,7 @@ public static int RenderInt(this Layout layout, LogEventInfo logEvent, int defau int result; // NumberStyles.Integer is default of Convert.ToInt16 - // CultureInfo.InvariantCulture is backwardscomp. + // CultureInfo.InvariantCulture is backwards-compatibility. if (!int.TryParse(rendered, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) { InternalLogger.Warn(layoutName + ": parse of value '" + rendered + "' failed, return " + defaultValue); diff --git a/src/NLog/Internal/NetworkSenders/HttpNetworkSender.cs b/src/NLog/Internal/NetworkSenders/HttpNetworkSender.cs index 4c929cf94e..436f67e60d 100644 --- a/src/NLog/Internal/NetworkSenders/HttpNetworkSender.cs +++ b/src/NLog/Internal/NetworkSenders/HttpNetworkSender.cs @@ -76,7 +76,7 @@ protected override void DoSend(byte[] bytes, int offset, int length, AsyncContin { using (var response = webRequest.EndGetResponse(r)) { - // Response succesfully read + // Response successfully read } // completed fine diff --git a/src/NLog/Internal/StringBuilderExt.cs b/src/NLog/Internal/StringBuilderExt.cs index c489928b0e..7cc88a091f 100644 --- a/src/NLog/Internal/StringBuilderExt.cs +++ b/src/NLog/Internal/StringBuilderExt.cs @@ -332,7 +332,7 @@ internal static void Append4DigitsZeroPadded(this StringBuilder builder, int num } /// - /// Apend a int type (byte, int) as string + /// Append a int type (byte, int) as string /// internal static void AppendIntegerAsString(this StringBuilder sb, IConvertible value, TypeCode objTypeCode) { diff --git a/src/NLog/Internal/XmlHelper.cs b/src/NLog/Internal/XmlHelper.cs index 7e8684bbee..081cfa6f16 100644 --- a/src/NLog/Internal/XmlHelper.cs +++ b/src/NLog/Internal/XmlHelper.cs @@ -214,7 +214,7 @@ internal static string XmlConvertToElementName(string xmlElementName, bool allow bool includeChr = false; switch (chr) { - case ':': // namespace-delimeter + case ':': // namespace-delimiter if (i != 0 && allowNamespace) { allowNamespace = false; diff --git a/src/NLog/LayoutRenderers/LayoutRenderer.cs b/src/NLog/LayoutRenderers/LayoutRenderer.cs index 2db14530d2..20fe4b0db6 100644 --- a/src/NLog/LayoutRenderers/LayoutRenderer.cs +++ b/src/NLog/LayoutRenderers/LayoutRenderer.cs @@ -258,7 +258,7 @@ public static void Register(string name) /// /// Register a custom layout renderer. /// - /// Short-cut for registing to default + /// Short-cut for registering to default /// Type of the layout renderer. /// Name of the layout renderer - without ${}. public static void Register(string name, Type layoutRendererType) @@ -268,7 +268,7 @@ public static void Register(string name, Type layoutRendererType) } /// - /// Register a custom layout renderer with a callback function . The callback recieves the logEvent. + /// Register a custom layout renderer with a callback function . The callback receives the logEvent. /// /// Name of the layout renderer - without ${}. /// Callback that returns the value for the layout renderer. diff --git a/src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs b/src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs index d443edd3dc..cfd41eb301 100644 --- a/src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs +++ b/src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs @@ -73,7 +73,7 @@ public RegistryLayoutRenderer() public Layout DefaultValue { get; set; } /// - /// Require escaping backward slashes in . Need to be backwardscompatible. + /// Require escaping backward slashes in . Need to be backwards-compatible. /// /// When true: /// diff --git a/src/NLog/LayoutRenderers/Wrappers/XmlEncodeLayoutRendererWrapper.cs b/src/NLog/LayoutRenderers/Wrappers/XmlEncodeLayoutRendererWrapper.cs index bbab581ab0..c29582d92a 100644 --- a/src/NLog/LayoutRenderers/Wrappers/XmlEncodeLayoutRendererWrapper.cs +++ b/src/NLog/LayoutRenderers/Wrappers/XmlEncodeLayoutRendererWrapper.cs @@ -66,7 +66,7 @@ public XmlEncodeLayoutRendererWrapper() public bool XmlEncode { get; set; } /// - /// Gets or sets a value indicating whether to tranform newlines (\r\n) into ( ) + /// Gets or sets a value indicating whether to transform newlines (\r\n) into ( ) /// /// [DefaultValue(false)] diff --git a/src/NLog/Layouts/Layout.cs b/src/NLog/Layouts/Layout.cs index c6af980ac4..29a7ac391c 100644 --- a/src/NLog/Layouts/Layout.cs +++ b/src/NLog/Layouts/Layout.cs @@ -118,7 +118,7 @@ public static Layout FromString(string layoutText, ConfigurationItemFactory conf /// Precalculates the layout for the specified log event and stores the result /// in per-log event cache. /// - /// Only if the layout doesn't have [ThreadAgnostic] and doens't contain layouts with [ThreadAgnostic]. + /// Only if the layout doesn't have [ThreadAgnostic] and doesn't contain layouts with [ThreadAgnostic]. /// /// The log event. /// @@ -291,7 +291,7 @@ internal void PerformObjectScanning() MutableUnsafe = objectGraphScannerList.Any(item => item.GetType().IsDefined(typeof(MutableUnsafeAttribute), true)); // determine the max StackTraceUsage, to decide if Logger needs to capture callsite - StackTraceUsage = StackTraceUsage.None; // Incase this Layout should implement IUsesStackTrace + StackTraceUsage = StackTraceUsage.None; // In case this Layout should implement IUsesStackTrace StackTraceUsage = objectGraphScannerList.OfType().DefaultIfEmpty().Max(item => item?.StackTraceUsage ?? StackTraceUsage.None); _scannedForObjects = true; @@ -335,7 +335,7 @@ protected virtual void CloseLayout() /// /// Register a custom Layout. /// - /// Short-cut for registing to default + /// Short-cut for registering to default /// Type of the Layout. /// Name of the Layout. public static void Register(string name) @@ -348,7 +348,7 @@ public static void Register(string name) /// /// Register a custom Layout. /// - /// Short-cut for registing to default + /// Short-cut for registering to default /// Type of the Layout. /// Name of the Layout. public static void Register(string name, Type layoutType) diff --git a/src/NLog/Layouts/LayoutParser.cs b/src/NLog/Layouts/LayoutParser.cs index 8e081b7e7c..403d10b009 100644 --- a/src/NLog/Layouts/LayoutParser.cs +++ b/src/NLog/Layouts/LayoutParser.cs @@ -78,7 +78,7 @@ internal static LayoutRenderer[] CompileLayout(ConfigurationItemFactory configur } else { - //dont treat \ as escape char and just read it + //don't treat \ as escape char and just read it literalBuf.Append('\\'); } continue; diff --git a/src/NLog/LogManager.cs b/src/NLog/LogManager.cs index 725467964b..341e3c3c6c 100644 --- a/src/NLog/LogManager.cs +++ b/src/NLog/LogManager.cs @@ -105,7 +105,7 @@ public static bool ThrowExceptions /// /// A value of true if exception should be thrown; otherwise, false. /// - /// This option is for backwards-compatiblity. + /// This option is for backwards-compatibility. /// By default exceptions are not thrown under any circumstances. /// /// diff --git a/src/NLog/MessageTemplates/ValueFormatter.cs b/src/NLog/MessageTemplates/ValueFormatter.cs index bb40d19461..f2bdbc6759 100644 --- a/src/NLog/MessageTemplates/ValueFormatter.cs +++ b/src/NLog/MessageTemplates/ValueFormatter.cs @@ -42,7 +42,7 @@ namespace NLog.MessageTemplates { /// - /// Convert Render or serialize a value, with optionnally backwardscompatible with + /// Convert Render or serialize a value, with optionally backwards-compatible with /// internal class ValueFormatter : IValueFormatter { diff --git a/src/NLog/Targets/AsyncTaskTarget.cs b/src/NLog/Targets/AsyncTaskTarget.cs index d14ed09e5f..b2f6e1d737 100644 --- a/src/NLog/Targets/AsyncTaskTarget.cs +++ b/src/NLog/Targets/AsyncTaskTarget.cs @@ -364,7 +364,7 @@ protected override void Dispose(bool disposing) /// /// Checks the internal queue for the next to create a new task for /// - /// Used for race-condition validation betweewn task-completion and timeout + /// Used for race-condition validation between task-completion and timeout /// Signals whether previousTask completed an almost full BatchSize private void TaskStartNext(object previousTask, bool fullBatchCompleted) { @@ -589,7 +589,7 @@ private void NotifyTaskCompletion(IList reusableContinuations } /// - /// Handles that scheduled task has completed (succesfully or failed), and starts the next pending task + /// Handles that scheduled task has completed (successfully or failed), and starts the next pending task /// /// Task just completed /// AsyncContinuation to notify of success or failure diff --git a/src/NLog/Targets/DefaultJsonSerializer.cs b/src/NLog/Targets/DefaultJsonSerializer.cs index d130be1056..185e79a903 100644 --- a/src/NLog/Targets/DefaultJsonSerializer.cs +++ b/src/NLog/Targets/DefaultJsonSerializer.cs @@ -152,7 +152,7 @@ public string SerializeObject(object value, JsonSerializeOptions options) ///
/// The object to serialize to JSON. /// Write the resulting JSON to this destination. - /// Object serialized succesfully (true/false). + /// Object serialized successfully (true/false). public bool SerializeObject(object value, StringBuilder destination) { return SerializeObject(value, destination, _serializeOptions); @@ -164,7 +164,7 @@ public bool SerializeObject(object value, StringBuilder destination) /// The object to serialize to JSON. /// Write the resulting JSON to this destination. /// serialisation options - /// Object serialized succesfully (true/false). + /// Object serialized successfully (true/false). public bool SerializeObject(object value, StringBuilder destination, JsonSerializeOptions options) { return SerializeObject(value, destination, options, default(SingleItemOptimizedHashSet), 0); @@ -178,7 +178,7 @@ public bool SerializeObject(object value, StringBuilder destination, JsonSeriali /// serialisation options /// The objects in path (Avoid cyclic reference loop). /// The current depth (level) of recursion. - /// Object serialized succesfully (true/false). + /// Object serialized successfully (true/false). private bool SerializeObject(object value, StringBuilder destination, JsonSerializeOptions options, SingleItemOptimizedHashSet objectsInPath, int depth) { int originalLength = destination.Length; diff --git a/src/NLog/Targets/FileTarget.cs b/src/NLog/Targets/FileTarget.cs index 3326bc18ab..f0e523f25c 100644 --- a/src/NLog/Targets/FileTarget.cs +++ b/src/NLog/Targets/FileTarget.cs @@ -64,14 +64,14 @@ namespace NLog.Targets public class FileTarget : TargetWithLayoutHeaderAndFooter, ICreateFileParameters { /// - /// Default clean up period of the initilized files. When a file exceeds the clean up period is removed from the list. + /// Default clean up period of the initialized files. When a file exceeds the clean up period is removed from the list. /// /// Clean up period is defined in days. private const int InitializedFilesCleanupPeriod = 2; /// - /// The maximum number of initialised files before clean up procedures are initiated, - /// to keep the number of initialised files to a minimum. Chose 25 to cater for monthly rolling of log-files. + /// The maximum number of initialized files before clean up procedures are initiated, + /// to keep the number of initialized files to a minimum. Chose 25 to cater for monthly rolling of log-files. /// private const int InitializedFilesCounterMax = 25; @@ -100,7 +100,7 @@ IFileArchiveMode GetFileArchiveHelper(string archiveFilePattern) private Timer _autoClosingTimer; /// - /// The number of initialised files at any one time. + /// The number of initialized files at any one time. /// private int _initializedFilesCounter; @@ -1479,7 +1479,7 @@ private string GetArchiveDateFormatString(string defaultFormat) private DateTime? GetArchiveDate(string fileName, LogEventInfo logEvent, DateTime previousLogEventTimestamp) { - // Using File LastModifed to handle FileArchivePeriod.Month (where file creation time is one month ago) + // Using File LastModified to handle FileArchivePeriod.Month (where file creation time is one month ago) var fileLastModifiedUtc = _fileAppenderCache.GetFileLastWriteTimeUtc(fileName); InternalLogger.Trace("FileTarget(Name={0}): Calculating archive date. File-LastModifiedUtc: {1}; Previous LogEvent-TimeStamp: {2}", Name, fileLastModifiedUtc, previousLogEventTimestamp); @@ -2154,7 +2154,7 @@ private void WriteToFile(string fileName, ArraySegment bytes, bool initial } /// - /// Initialise a file to be used by the instance. Based on the number of initialised + /// Initialise a file to be used by the instance. Based on the number of initialized /// files and the values of various instance properties clean up and/or archiving processes can be invoked. /// /// File name to be written. diff --git a/src/NLog/Targets/JsonSerializeOptions.cs b/src/NLog/Targets/JsonSerializeOptions.cs index 40331201d2..78e5bbfccd 100644 --- a/src/NLog/Targets/JsonSerializeOptions.cs +++ b/src/NLog/Targets/JsonSerializeOptions.cs @@ -42,7 +42,7 @@ namespace NLog.Targets public class JsonSerializeOptions { /// - /// Add quotes arround object keys? + /// Add quotes around object keys? /// [DefaultValue(true)] public bool QuoteKeys { get; set; } diff --git a/src/NLog/Targets/MailTarget.cs b/src/NLog/Targets/MailTarget.cs index 0816367a9b..1723d7751d 100644 --- a/src/NLog/Targets/MailTarget.cs +++ b/src/NLog/Targets/MailTarget.cs @@ -324,7 +324,7 @@ public Layout Body /// /// Gets or sets a value indicating the SMTP client timeout. /// - /// Warning: zero is not infinit waiting + /// Warning: zero is not infinite waiting /// [DefaultValue(10000)] public int Timeout { get; set; } diff --git a/src/NLog/Targets/Target.cs b/src/NLog/Targets/Target.cs index 58ae68e050..b358f3188b 100644 --- a/src/NLog/Targets/Target.cs +++ b/src/NLog/Targets/Target.cs @@ -771,7 +771,7 @@ private static bool TryGetCachedValue(Layout layout, LogEventInfo logEvent, out /// /// Register a custom Target. /// - /// Short-cut for registing to default + /// Short-cut for registering to default /// Type of the Target. /// Name of the Target. public static void Register(string name) @@ -784,7 +784,7 @@ public static void Register(string name) /// /// Register a custom Target. /// - /// Short-cut for registing to default + /// Short-cut for registering to default /// Type of the Target. /// Name of the Target. public static void Register(string name, Type targetType) diff --git a/src/NLog/Targets/WebServiceTarget.cs b/src/NLog/Targets/WebServiceTarget.cs index 11020ec17f..0ea42ed908 100644 --- a/src/NLog/Targets/WebServiceTarget.cs +++ b/src/NLog/Targets/WebServiceTarget.cs @@ -364,7 +364,7 @@ private AsyncContinuation CreateSendContinuation(AsyncContinuation continuation, { using (var response = request.EndGetResponse(r)) { - // Request succesfully initialized + // Request successfully initialized } DoInvokeCompleted(continuation, null); diff --git a/src/NLog/Targets/Wrappers/AsyncTargetWrapper.cs b/src/NLog/Targets/Wrappers/AsyncTargetWrapper.cs index c5cf57d476..d1fe1d3b75 100644 --- a/src/NLog/Targets/Wrappers/AsyncTargetWrapper.cs +++ b/src/NLog/Targets/Wrappers/AsyncTargetWrapper.cs @@ -155,7 +155,7 @@ public AsyncTargetWrapper(Target wrappedTarget, int queueLimit, AsyncTargetWrapp /// /// Raise event when Target cannot store LogEvent. - /// Event arg contains losed LogEvent + /// Event arg contains lost LogEvents /// public event EventHandler LogEventDropped { diff --git a/src/NLog/Targets/Wrappers/AutoFlushTargetWrapper.cs b/src/NLog/Targets/Wrappers/AutoFlushTargetWrapper.cs index adc2da8080..2a55901f19 100644 --- a/src/NLog/Targets/Wrappers/AutoFlushTargetWrapper.cs +++ b/src/NLog/Targets/Wrappers/AutoFlushTargetWrapper.cs @@ -38,7 +38,7 @@ namespace NLog.Targets.Wrappers using NLog.Internal; /// - /// Causes a flush on a wrapped target if LogEvent statisfies the . + /// Causes a flush on a wrapped target if LogEvent satisfies the . /// If condition isn't set, flushes on each write. /// /// Documentation on NLog Wiki diff --git a/tests/NLog.UnitTests/Conditions/ConditionEvaluatorTests.cs b/tests/NLog.UnitTests/Conditions/ConditionEvaluatorTests.cs index f30cbdc70b..fd874b2341 100644 --- a/tests/NLog.UnitTests/Conditions/ConditionEvaluatorTests.cs +++ b/tests/NLog.UnitTests/Conditions/ConditionEvaluatorTests.cs @@ -81,7 +81,7 @@ public void ConditionMethodsTest() AssertEvaluationResult(true, "regex-matches('foo', '^foo$')"); AssertEvaluationResult(false, "regex-matches('foo', '^bar$')"); - //Check that calling with empty strign is equivalent with not passing the parameter + //Check that calling with empty string is equivalent with not passing the parameter AssertEvaluationResult(true, "regex-matches('foo', '^foo$', '')"); AssertEvaluationResult(false, "regex-matches('foo', '^bar$', '')"); @@ -242,7 +242,7 @@ public void TypePromotionTest() Assert.Equal(false, ConditionParser.ParseExpression("false == ToInt16(4)", factories).Evaluate(CreateWellKnownContext())); Assert.Equal(false, ConditionParser.ParseExpression("ToInt16(1) == false", factories).Evaluate(CreateWellKnownContext())); - //this is doing string comparision as thats the common type which works in this case. + //this is doing string comparision as that's the common type which works in this case. Assert.Equal(false, ConditionParser.ParseExpression("ToDateTime('2010/01/01') == '20xx/01/01'", factories).Evaluate(CreateWellKnownContext())); } diff --git a/tests/NLog.UnitTests/Config/ExtensionTests.cs b/tests/NLog.UnitTests/Config/ExtensionTests.cs index eac4d56bb3..e7a870ffd3 100644 --- a/tests/NLog.UnitTests/Config/ExtensionTests.cs +++ b/tests/NLog.UnitTests/Config/ExtensionTests.cs @@ -503,13 +503,13 @@ public void Extensions_NLogPackageLoader_should_beCalled() var logs = writer.ToString(); - Assert.Contains("Preload succesfully invoked for 'LoaderTestInternal.NLogPackageLoader'", logs); - Assert.Contains("Preload succesfully invoked for 'LoaderTestPublic.NLogPackageLoader'", logs); - Assert.Contains("Preload succesfully invoked for 'LoaderTestPrivateNestedStatic.SomeType+NLogPackageLoader'", logs); - Assert.Contains("Preload succesfully invoked for 'LoaderTestPrivateNested.SomeType+NLogPackageLoader'", logs); + Assert.Contains("Preload successfully invoked for 'LoaderTestInternal.NLogPackageLoader'", logs); + Assert.Contains("Preload successfully invoked for 'LoaderTestPublic.NLogPackageLoader'", logs); + Assert.Contains("Preload successfully invoked for 'LoaderTestPrivateNestedStatic.SomeType+NLogPackageLoader'", logs); + Assert.Contains("Preload successfully invoked for 'LoaderTestPrivateNested.SomeType+NLogPackageLoader'", logs); - //4 times succesful - Assert.Equal(4, Regex.Matches(logs, Regex.Escape("Preload succesfully invoked for '")).Count); + //4 times successful + Assert.Equal(4, Regex.Matches(logs, Regex.Escape("Preload successfully invoked for '")).Count); } finally diff --git a/tests/NLog.UnitTests/Internal/FileAppenders/FileAppenderCacheTests.cs b/tests/NLog.UnitTests/Internal/FileAppenders/FileAppenderCacheTests.cs index bcdf95e155..d4b11632d8 100644 --- a/tests/NLog.UnitTests/Internal/FileAppenders/FileAppenderCacheTests.cs +++ b/tests/NLog.UnitTests/Internal/FileAppenders/FileAppenderCacheTests.cs @@ -124,7 +124,7 @@ public void FileAppenderCache_InvalidateAppender() // for the file. // - // Write, flush the content into the file and release the file. This happens throught the + // Write, flush the content into the file and release the file. This happens through the // InvalidateAppender() method. We need to release the file before invoking AssertFileContents() method. appender.Write(StringToBytes("NLog test string.")); cache.InvalidateAppender(tempFile); diff --git a/tests/NLog.UnitTests/Internal/LayoutHelpersTests.cs b/tests/NLog.UnitTests/Internal/LayoutHelpersTests.cs index 62131ac023..77303c39b4 100644 --- a/tests/NLog.UnitTests/Internal/LayoutHelpersTests.cs +++ b/tests/NLog.UnitTests/Internal/LayoutHelpersTests.cs @@ -97,7 +97,7 @@ public void TestRenderShort(string input, short expected) /// - /// test with both default. True or false, case insentive, no numbers + /// test with both default. True or false, case-insensitive, no numbers /// /// /// null = default diff --git a/tests/NLog.UnitTests/LayoutRenderers/ExceptionTests.cs b/tests/NLog.UnitTests/LayoutRenderers/ExceptionTests.cs index 0adbf252de..2b7726a2b4 100644 --- a/tests/NLog.UnitTests/LayoutRenderers/ExceptionTests.cs +++ b/tests/NLog.UnitTests/LayoutRenderers/ExceptionTests.cs @@ -654,7 +654,7 @@ private void SetConfigurationForExceptionUsingRootMethodTests() } /// - /// Get an excption with stacktrace by genating a exception + /// Get an exception with stacktrace by generating a exception /// /// /// diff --git a/tests/NLog.UnitTests/Layouts/SimpleLayoutParserTests.cs b/tests/NLog.UnitTests/Layouts/SimpleLayoutParserTests.cs index 0a7636e74a..d3320adc57 100644 --- a/tests/NLog.UnitTests/Layouts/SimpleLayoutParserTests.cs +++ b/tests/NLog.UnitTests/Layouts/SimpleLayoutParserTests.cs @@ -535,7 +535,7 @@ public void InvalidLayoutWillThrowIfExceptionThrowingIsOn() /// /// - /// Test layout with Genernic List type. - is the seperator + /// Test layout with Generic List type. - is the separator /// /// /// diff --git a/tests/NLog.UnitTests/LogReceiverService/LogReceiverServiceTests.cs b/tests/NLog.UnitTests/LogReceiverService/LogReceiverServiceTests.cs index f35482ac11..0e7967ee37 100644 --- a/tests/NLog.UnitTests/LogReceiverService/LogReceiverServiceTests.cs +++ b/tests/NLog.UnitTests/LogReceiverService/LogReceiverServiceTests.cs @@ -320,7 +320,7 @@ private void RealTestLogReciever(bool useOneWayContract, bool binaryEncode) "); - ExecLogRecieverAndCheck(ExecLogging1, CheckRecieved1, 2); + ExecLogRecieverAndCheck(ExecLogging1, CheckReceived1, 2); } @@ -328,7 +328,7 @@ private void RealTestLogReciever(bool useOneWayContract, bool binaryEncode) /// Create WCF service, logs and listen to the events /// /// function for logging the messages - /// function for checking the received messsages + /// function for checking the received messages /// message count for wait for listen and checking private void ExecLogRecieverAndCheck(Action logFunc, Action> logCheckFunc, int messageCount) { @@ -356,7 +356,7 @@ private void ExecLogRecieverAndCheck(Action logFunc, Action(); + LogRecieverMock.receivedEvents = new List(); LogRecieverMock.CountdownEvent = countdownEvent; var logger1 = LogManager.GetLogger("logger1"); @@ -365,27 +365,27 @@ private void ExecLogRecieverAndCheck(Action logFunc, Action recieved) + private static void CheckReceived1(List received) { //in some case the messages aren't retrieved in the right order when invoked in the same sec. //more important is that both are retrieved with the correct info - Assert.Equal(2, recieved.Count); + Assert.Equal(2, received.Count); - var logmessages = new HashSet { recieved[0].ToEventInfo().First().Message, recieved[1].ToEventInfo().First().Message }; + var logmessages = new HashSet { received[0].ToEventInfo().First().Message, received[1].ToEventInfo().First().Message }; Assert.True(logmessages.Contains("test 1"), "message 1 is missing"); Assert.True(logmessages.Contains("test 2"), "message 2 is missing"); @@ -405,7 +405,7 @@ public class LogRecieverMock : ILogReceiverServer, ILogReceiverOneWayServer public static CountdownEvent CountdownEvent; - public static List recievedEvents = new List(); + public static List receivedEvents = new List(); /// /// Processes the log messages. @@ -420,7 +420,7 @@ public void ProcessLogMessages(NLogEvents events) - recievedEvents.Add(events); + receivedEvents.Add(events); CountdownEvent.Signal(); } diff --git a/tests/NLog.UnitTests/LoggerTests.cs b/tests/NLog.UnitTests/LoggerTests.cs index e76d879fc2..2efce85695 100644 --- a/tests/NLog.UnitTests/LoggerTests.cs +++ b/tests/NLog.UnitTests/LoggerTests.cs @@ -1853,7 +1853,7 @@ public void SingleTargetMessageFormatOptimizationTest() [InlineData(true, "@Client", "1")] [InlineData(true, "0", "1")] [InlineData(false, "0", "1")] - [InlineData(true, "OrderId", "Client")] //succeeeds, but gives JSON like (no quoted key, missing quotes arround string, =, other spacing) + [InlineData(true, "OrderId", "Client")] //succeeds, but gives JSON like (no quoted key, missing quotes around string, =, other spacing) [InlineData(true, "OrderId", "@Client")] [InlineData(null, "OrderId", "@Client")] public void MixedStructuredEventsConfigTest(bool? parseMessageTemplates, string param1, string param2) @@ -2417,7 +2417,7 @@ public void LogEventTemplateShouldOverrideProperties() Assert.Equal(2, target.LastEvent.Properties.Count); AssertContainsInDictionary(target.LastEvent.Properties, "Stage", 1); AssertContainsInDictionary(target.LastEvent.Properties, "userid", "kermit"); - loggerStage2.Trace("Login succesful for {userid}", "kermit"); + loggerStage2.Trace("Login successful for {userid}", "kermit"); Assert.Equal(2, target.LastEvent.Properties.Count); AssertContainsInDictionary(target.LastEvent.Properties, "Stage", 2); AssertContainsInDictionary(target.LastEvent.Properties, "userid", "kermit"); diff --git a/tests/NLog.UnitTests/Targets/ColoredConsoleTargetTests.cs b/tests/NLog.UnitTests/Targets/ColoredConsoleTargetTests.cs index 207abcc597..7197ef6657 100644 --- a/tests/NLog.UnitTests/Targets/ColoredConsoleTargetTests.cs +++ b/tests/NLog.UnitTests/Targets/ColoredConsoleTargetTests.cs @@ -196,7 +196,7 @@ public void ColoredConsoleAnsi_RowColorWithWordHighlight_VerificationTest() } /// - /// With or wihout CompileRegex, CompileRegex is never null, even if not used when CompileRegex=false. (needed for backwardscomp) + /// With or without CompileRegex, CompileRegex is never null, even if not used when CompileRegex=false. (needed for backwards-compatibility) /// /// [Theory] diff --git a/tests/NLog.UnitTests/Targets/ConcurrentFileTargetTests.cs b/tests/NLog.UnitTests/Targets/ConcurrentFileTargetTests.cs index 63cdb56dbd..4a889cb780 100644 --- a/tests/NLog.UnitTests/Targets/ConcurrentFileTargetTests.cs +++ b/tests/NLog.UnitTests/Targets/ConcurrentFileTargetTests.cs @@ -202,11 +202,11 @@ private void DoConcurrentTest(int numProcesses, int numLogs, string mode) bool verifyFileSize = files.Count > 1; - var recievedNumbersSet = new List[numProcesses]; + var receivedNumbersSet = new List[numProcesses]; for (int i = 0; i < numProcesses; i++) { - var recievedNumbers = new List(numLogs); - recievedNumbersSet[i] = recievedNumbers; + var receivedNumbers = new List(numLogs); + receivedNumbersSet[i] = receivedNumbers; } //Console.WriteLine("Verifying output file {0}", logFile); @@ -226,7 +226,7 @@ private void DoConcurrentTest(int numProcesses, int numLogs, string mode) int number = Convert.ToInt32(tokens[1]); Assert.True(thread >= 0); Assert.True(thread < numProcesses); - recievedNumbersSet[thread].Add(number); + receivedNumbersSet[thread].Add(number); } @@ -250,23 +250,23 @@ private void DoConcurrentTest(int numProcesses, int numLogs, string mode) { for (; currentProcess < numProcesses; currentProcess++) { - var recievedNumbers = recievedNumbersSet[currentProcess]; + var receivedNumbers = receivedNumbersSet[currentProcess]; - var equalLength = expected.Count == recievedNumbers.Count; + var equalLength = expected.Count == receivedNumbers.Count; - var fastCheck = equalLength && expected.SequenceEqual(recievedNumbers); + var fastCheck = equalLength && expected.SequenceEqual(receivedNumbers); if (!fastCheck) //assert equals on two long lists in xUnit is lame. Not showing the difference. { if (equalLength) { - var reodered = recievedNumbers.OrderBy(i => i); + var reodered = receivedNumbers.OrderBy(i => i); equalsWhenReorderd = expected.SequenceEqual(reodered); } - Assert.Equal(string.Join(",", expected), string.Join(",", recievedNumbers)); + Assert.Equal(string.Join(",", expected), string.Join(",", receivedNumbers)); } } } @@ -297,7 +297,7 @@ private void DoConcurrentTest(int numProcesses, int numLogs, string mode) [InlineData(5, 4000, "none")] [InlineData(10, 2000, "none")] #if !MONO - // MONO Doesn't work well with global mutex, and it is needed for succesful concurrent archive operations + // MONO Doesn't work well with global mutex, and it is needed for successful concurrent archive operations [InlineData(2, 500, "none|archive")] [InlineData(2, 500, "none|mutex|archive")] [InlineData(2, 10000, "none|mutex")] @@ -317,7 +317,7 @@ public void SimpleConcurrentTest(int numProcesses, int numLogs, string mode) public void AsyncConcurrentTest(string mode) { // Before 2 processes are running into concurrent writes, - // the first process typically already has written couple thousend events. + // the first process typically already has written couple thousand events. // Thus to have a meaningful test, at least 10K events are required. // Due to the buffering it makes no big difference in runtime, whether we // have 2 process writing 10K events each or couple more processes with even more events. diff --git a/tests/NLog.UnitTests/Targets/FileTargetTests.cs b/tests/NLog.UnitTests/Targets/FileTargetTests.cs index 594432b8e9..9c9c98f308 100644 --- a/tests/NLog.UnitTests/Targets/FileTargetTests.cs +++ b/tests/NLog.UnitTests/Targets/FileTargetTests.cs @@ -274,7 +274,7 @@ public void SimpleFileTestWriteBom() #if !MONO /// - /// If a drive doesn't existing, before repeatatly creating a dir was tried. This test was taking +60 seconds + /// If a drive doesn't existing, before repeatably creating a dir was tried. This test was taking +60 seconds /// [Theory] [MemberData(nameof(SimpleFileTest_TestParameters))] @@ -992,7 +992,7 @@ public void SequentialArchiveTest() Path.Combine(archiveFolder, "0003.txt"), StringRepeat(times, "ddd\n"), Encoding.UTF8); - //0000 should not extists because of MaxArchiveFiles=3 + //0000 should not exists because of MaxArchiveFiles=3 Assert.True(!File.Exists(Path.Combine(archiveFolder, "0000.txt"))); Assert.True(!File.Exists(Path.Combine(archiveFolder, "0004.txt"))); } @@ -1198,7 +1198,7 @@ public void DeleteArchiveFilesByDate() //two files should still be there Assert.Equal(files.ElementAt(1), files2.ElementAt(0)); Assert.Equal(files.ElementAt(2), files2.ElementAt(1)); - //one new archive file shoud be created + //one new archive file should be created Assert.DoesNotContain(files2.ElementAt(2), files); } finally @@ -1846,7 +1846,7 @@ public void DeleteArchiveFilesByDate_AlteredMaxArchive() Assert.DoesNotContain(files.ElementAt(3), files2); //one files should still be there Assert.Equal(files.ElementAt(4), files2.ElementAt(0)); - //one new archive file shoud be created + //one new archive file should be created Assert.DoesNotContain(files2.ElementAt(1), files); } finally diff --git a/tests/NLog.UnitTests/Targets/WebServiceTargetTests.cs b/tests/NLog.UnitTests/Targets/WebServiceTargetTests.cs index 6010524744..1f3e8dbd7c 100644 --- a/tests/NLog.UnitTests/Targets/WebServiceTargetTests.cs +++ b/tests/NLog.UnitTests/Targets/WebServiceTargetTests.cs @@ -297,9 +297,9 @@ public void WebserviceTest_restapi_httppost() }); Assert.Equal(0, LogMeController.CountdownEvent.CurrentCount); - Assert.Equal(2, LogMeController.RecievedLogsPostParam1.Count); - CheckQueueMessage(message1, LogMeController.RecievedLogsPostParam1); - CheckQueueMessage(message2, LogMeController.RecievedLogsPostParam1); + Assert.Equal(2, LogMeController.ReceivedLogsPostParam1.Count); + CheckQueueMessage(message1, LogMeController.ReceivedLogsPostParam1); + CheckQueueMessage(message2, LogMeController.ReceivedLogsPostParam1); } /// @@ -323,9 +323,9 @@ public void WebserviceTest_restapi_httpget() Assert.Equal(0, LogMeController.CountdownEvent.CurrentCount); - Assert.Equal(2, LogMeController.RecievedLogsGetParam1.Count); - CheckQueueMessage(message1, LogMeController.RecievedLogsGetParam1); - CheckQueueMessage(message2, LogMeController.RecievedLogsGetParam1); + Assert.Equal(2, LogMeController.ReceivedLogsGetParam1.Count); + CheckQueueMessage(message1, LogMeController.ReceivedLogsGetParam1); + CheckQueueMessage(message2, LogMeController.ReceivedLogsGetParam1); } /// @@ -355,7 +355,7 @@ public void WebserviceTest_restapi_httpget_flush() LogManager.Flush(); // Nothing to flush }); - Assert.Equal(100, LogMeController.RecievedLogsGetParam1.Count); + Assert.Equal(100, LogMeController.ReceivedLogsGetParam1.Count); } [Fact] @@ -373,8 +373,8 @@ public void WebServiceTest_restapi_httpget_querystring() Assert.Equal(0, LogMeController.CountdownEvent.CurrentCount); - Assert.Single(LogMeController.RecievedLogsGetParam1); - CheckQueueMessage("another message", LogMeController.RecievedLogsGetParam1); + Assert.Single(LogMeController.ReceivedLogsGetParam1); + CheckQueueMessage("another message", LogMeController.ReceivedLogsGetParam1); } private static Logger SetUpHttpGetWebservice(string relativeUrl) @@ -406,9 +406,9 @@ private static Logger SetUpHttpGetWebservice(string relativeUrl) return logger; } - private static void CheckQueueMessage(string message1, ConcurrentBag recievedLogsGetParam1) + private static void CheckQueueMessage(string message1, ConcurrentBag receivedLogsGetParam1) { - var success = recievedLogsGetParam1.Contains(message1); + var success = receivedLogsGetParam1.Contains(message1); Assert.True(success, $"message '{message1}' not found"); } @@ -478,8 +478,8 @@ public void WebserviceTest_restapi_httppost_checkingLost() }); Assert.Equal(0, LogMeController.CountdownEvent.CurrentCount); - Assert.Equal(createdMessages.Count, LogMeController.RecievedLogsPostParam1.Count); - //Assert.Equal(createdMessages, ValuesController.RecievedLogsPostParam1); + Assert.Equal(createdMessages.Count, LogMeController.ReceivedLogsPostParam1.Count); + //Assert.Equal(createdMessages, ValuesController.ReceivedLogsPostParam1); }); } @@ -744,8 +744,8 @@ public class LogMeController : ApiController /// public static void ResetState(int expectedMessages) { - RecievedLogsPostParam1 = new ConcurrentBag(); - RecievedLogsGetParam1 = new ConcurrentBag(); + ReceivedLogsPostParam1 = new ConcurrentBag(); + ReceivedLogsGetParam1 = new ConcurrentBag(); if (expectedMessages > 0) CountdownEvent = new CountdownEvent(expectedMessages); else @@ -759,13 +759,13 @@ public static void ResetState(int expectedMessages) /// - /// Recieved param1 values (get) + /// Received param1 values (get) /// - public static ConcurrentBag RecievedLogsGetParam1 = new ConcurrentBag(); + public static ConcurrentBag ReceivedLogsGetParam1 = new ConcurrentBag(); /// - /// Recieved param1 values(post) + /// Received param1 values(post) /// - public static ConcurrentBag RecievedLogsPostParam1 = new ConcurrentBag(); + public static ConcurrentBag ReceivedLogsPostParam1 = new ConcurrentBag(); /// @@ -802,7 +802,7 @@ public string Get(int id) public IEnumerable Get(string param1 = "", string param2 = "") { - RecievedLogsGetParam1.Add(param1); + ReceivedLogsGetParam1.Add(param1); if (CountdownEvent != null) { CountdownEvent.Signal(); @@ -821,7 +821,7 @@ public void Post([FromBody] ComplexType complexType) { throw new ArgumentNullException(nameof(complexType)); } - RecievedLogsPostParam1.Add(complexType.Param1); + ReceivedLogsPostParam1.Add(complexType.Param1); if (CountdownEvent != null) { @@ -855,7 +855,7 @@ internal static void StartOwinTest(Action testsFunc) { testsFunc(); - //wait for all recieved message, or timeout. There is no exception on timeout, so we have to check carefully in the unit test. + //wait for all received message, or timeout. There is no exception on timeout, so we have to check carefully in the unit test. if (LogMeController.CountdownEvent != null) { LogMeController.CountdownEvent.Wait(webserviceCheckTimeoutMs); diff --git a/tests/NLog.UnitTests/Targets/Wrappers/LimitingTargetWrapperTests.cs b/tests/NLog.UnitTests/Targets/Wrappers/LimitingTargetWrapperTests.cs index 64c739f9ce..42d7b6d7dc 100644 --- a/tests/NLog.UnitTests/Targets/Wrappers/LimitingTargetWrapperTests.cs +++ b/tests/NLog.UnitTests/Targets/Wrappers/LimitingTargetWrapperTests.cs @@ -218,7 +218,7 @@ public void TestWritingMessagesOverMultipleIntervals() Thread.Sleep(20); lastException = WriteNumberAsyncLogEventsStartingAt(30, 10, wrapper); - //No more messages shouldve been written, since we are still in the third interval. + //No more messages should be been written, since we are still in the third interval. Assert.Equal(15, wrappedTarget.WriteCount); Assert.Equal("Hello 24", wrappedTarget.LastWrittenMessage); Assert.Null(lastException); From 6c5cee0b2df841253c2f71507864bf4e5bce8ee7 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Thu, 13 Jun 2019 23:29:07 +0200 Subject: [PATCH 11/15] fix typo --- src/NLog/Common/InternalLogger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NLog/Common/InternalLogger.cs b/src/NLog/Common/InternalLogger.cs index 809c6500b9..9feb926acf 100644 --- a/src/NLog/Common/InternalLogger.cs +++ b/src/NLog/Common/InternalLogger.cs @@ -452,7 +452,7 @@ private static void WriteToErrorConsole(string message) /// A message to write. /// /// Works when property set to true. - /// The is used in Debug and Relaese configuration. + /// The is used in Debug and Release configuration. /// The works only in Debug configuration and this is reason why is replaced by . /// in DEBUG /// From cc821003c3608cd83ed7c848dd492884e3513753 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Thu, 13 Jun 2019 23:31:43 +0200 Subject: [PATCH 12/15] Changelog NLog 4.6.5 --- CHANGELOG.md | 23 +++++++++++++++++++++++ src/NLog/NLog.csproj | 33 ++++++++++++--------------------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 427270e728..3c51f13455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,29 @@ Date format: (year/month/day) ## Change Log +### V4.6.5 (2019/06/13) + +#### Bugfixes + +- [#3476](https://github.com/NLog/NLog/pull/3476) Fix broken XSD schema - NLog.Schema package (@snakefoot, @304NotModified) + +#### Features + +- [#3478](https://github.com/NLog/NLog/pull/3478) XSD: Support in (@304NotModified) +- [#3477](https://github.com/NLog/NLog/pull/3477) ${AppSetting} - Added support for ConnectionStrings Lookup (@snakefoot) +- [#3469](https://github.com/NLog/NLog/pull/3469) LogLevel - Added support for TypeConverter (@snakefoot) +- [#3453](https://github.com/NLog/NLog/pull/3453) Added null terminator line ending for network target (@Kahath) +- [#3442](https://github.com/NLog/NLog/pull/3442) Log4JXmlEventLayout - Added IncludeCallSite + IncludeSourceInfo (@snakefoot) + +#### Improvements + +- [#3482](https://github.com/NLog/NLog/pull/3482) Fix typos in docs and comments (@304NotModified) + +#### Performance + +- [#3444](https://github.com/NLog/NLog/pull/3444) RetryingMultiProcessFileAppender - better init BufferSize (@snakefoot) + + ### V4.6.4 (2019/05/28) #### Bugfixes diff --git a/src/NLog/NLog.csproj b/src/NLog/NLog.csproj index e660eb71f2..d5620da39a 100644 --- a/src/NLog/NLog.csproj +++ b/src/NLog/NLog.csproj @@ -31,34 +31,25 @@ For ASP.NET Core, check: https://www.nuget.org/packages/NLog.Web.AspNetCore Copyright (c) 2004-$(CurrentYear) NLog Project - https://nlog-project.org/ +Bugfixes -Bugfixes: +- Fix broken XSD schema - NLog.Schema package (@snakefoot, @304NotModified) -- NLog.Schema: Added missing defaultAction attribute on filters element in XSD (@304NotModified) -- AsyncWrapper in Blocking Mode can cause deadlock (@snakefoot) +Features -Features: +- XSD: Support <value> in <variable> (@304NotModified) +- ${AppSetting} - Added support for ConnectionStrings Lookup (@snakefoot) +- LogLevel - Added support for TypeConverter (@snakefoot) +- Added null terminator line ending for network target (@Kahath) +- Log4JXmlEventLayout - Added IncludeCallSite + IncludeSourceInfo (@snakefoot) -- Added "Properties" property on Logger for reading and editing properties.(@snakefoot, @304NotModified) -- ${all-event-properties}: Added IncludeEmptyValues option (@304NotModified) -- ${when}, support for non-string values (@304NotModified) -- ${whenEmpty} support for non-string values (@snakefoot, @304NotModified) -- Added ${environment-user} (@snakefoot) -- Log4JXmlEventLayout - Added support for configuration of Parameters (@snakefoot) -- LoggingConfigurationParser - Recognize LoggingRule.RuleName property (@snakefoot) +Improvements -Improvements: +- Fix typos in docs and comments (@304NotModified) -- Update package descriptions to note the issues with <PackageReference> (@304NotModified) -- Various XSD improvements (NLog.Schema package) (@304NotModified) +Performance -Performance: - -- ${whenEmpty} faster rendering of string values (@snakefoot, @304NotModified) -- FilteringTargetWrapper: Add support for batch writing (@snakefoot, @304NotModified) -- PostFilteringTargetWrapper: performance optimizations (@snakefoot, @304NotModified) -- Async / buffering wrapper: Improve performance when blocking (@snakefoot) -- ObjectReflectionCache - Skip property-reflection for IFormattable (@snakefoot) +- RetryingMultiProcessFileAppender - better init BufferSize (@snakefoot) Full changelog: https://github.com/NLog/NLog/blob/master/CHANGELOG.md From 739b86233ca1d621332413d374a39479f10bbd40 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Thu, 13 Jun 2019 23:32:25 +0200 Subject: [PATCH 13/15] Version 4.6.5 --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index f57e4508d9..760d383ea2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -5,7 +5,7 @@ dotnet --version # dotnet restore .\src\NLog\ # dotnet pack .\src\NLog\ --configuration release --include-symbols -o ..\..\artifacts -$versionPrefix = "4.6.4" +$versionPrefix = "4.6.5" $versionSuffix = "" $versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER} $versionProduct = $versionPrefix; From 15686063dcc5e3f5438eb13933ef7e7243c1199b Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Fri, 14 Jun 2019 01:13:39 +0200 Subject: [PATCH 14/15] Fix XSD generation --- tools/MakeNLogXSD/XsdFileGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/MakeNLogXSD/XsdFileGenerator.cs b/tools/MakeNLogXSD/XsdFileGenerator.cs index fbef5ebf03..a778ec1233 100644 --- a/tools/MakeNLogXSD/XsdFileGenerator.cs +++ b/tools/MakeNLogXSD/XsdFileGenerator.cs @@ -208,7 +208,7 @@ private static XElement GetAttributeElement(XElement propertyElement) } else { - string xsdType = GetXsdType(propertyType, false); + string xsdType = GetXsdType(propertyType, true); if (xsdType == null) return null; From 1fb0b975400de74d163ec5313a4b452cf1a7ba68 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Fri, 14 Jun 2019 01:18:54 +0200 Subject: [PATCH 15/15] XSD test for NLog.Schema (#3487) * Added XSD test * Integrate into build script --- Test-XmlFile.ps1 | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ run-tests.ps1 | 7 ++++++ 2 files changed, 64 insertions(+) create mode 100644 Test-XmlFile.ps1 diff --git a/Test-XmlFile.ps1 b/Test-XmlFile.ps1 new file mode 100644 index 0000000000..ef898afa50 --- /dev/null +++ b/Test-XmlFile.ps1 @@ -0,0 +1,57 @@ +function Test-XmlFile +{ + <# + from: https://stackoverflow.com/a/16618560/201303 + + .Synopsis + Validates an xml file against an xml schema file. + .Example + PS> dir *.xml | Test-XmlFile schema.xsd + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory=$true)] + [string] $SchemaFile, + + [Parameter(ValueFromPipeline=$true, Mandatory=$true, ValueFromPipelineByPropertyName=$true)] + [alias('Fullname')] + [string] $XmlFile, + + [scriptblock] $ValidationEventHandler = { Write-Error $args[1].Exception } + ) + + begin { + $schemaReader = New-Object System.Xml.XmlTextReader $SchemaFile + $schema = [System.Xml.Schema.XmlSchema]::Read($schemaReader, $ValidationEventHandler) + } + + process { + $ret = $true + try { + $xml = New-Object System.Xml.XmlDocument + $xml.Schemas.Add($schema) | Out-Null + $xml.Load($XmlFile) + $xml.Validate({ + throw ([PsCustomObject] @{ + SchemaFile = $SchemaFile + XmlFile = $XmlFile + Exception = $args[1].Exception + }) + }) + } catch { + Write-Error $_ + $ret = $false + } + $ret + } + + end { + $schemaReader.Close() + } +} + +# Needs absolute paths. Will throw a error if one of the files is not found +$pwd = get-location; + +# Returns true if valid +return Test-XmlFile "$pwd\src\NLog\bin\Release\NLog.xsd" "$pwd\src\NuGet\NLog.Config\content\NLog.config" diff --git a/run-tests.ps1 b/run-tests.ps1 index 51468be92d..0413e94d49 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -1,3 +1,10 @@ + +if(.\Test-XmlFile.ps1){ + Write-Output "Valid XSD" +}else { + exit 400; +} + dotnet restore .\src\NLog\ if (-Not $LastExitCode -eq 0) { exit $LastExitCode }