diff --git a/NLog.Windows.Forms.Tests/NLog.Windows.Forms.Tests.csproj b/NLog.Windows.Forms.Tests/NLog.Windows.Forms.Tests.csproj index 3ec5037..46330af 100644 --- a/NLog.Windows.Forms.Tests/NLog.Windows.Forms.Tests.csproj +++ b/NLog.Windows.Forms.Tests/NLog.Windows.Forms.Tests.csproj @@ -1,12 +1,11 @@  - net452 + net452;netcoreapp3.1;net5.0-windows ..\ NLog.Windows.Forms.Tests Microsoft NLog.Windows.Forms.Tests - Copyright © Jaroslaw Kowalski, Kim Christensen, Julian Verdurmen 2015-2016 - bin\$(Configuration)\ + Copyright © Jaroslaw Kowalski, Kim Christensen, Julian Verdurmen full @@ -20,6 +19,10 @@ NLog.snk + + + $(DefineConstants);LINKS_SUPPORTED + diff --git a/NLog.Windows.Forms.Tests/RichTextBoxTargetTests.cs b/NLog.Windows.Forms.Tests/RichTextBoxTargetTests.cs index cef1ebe..93a926a 100644 --- a/NLog.Windows.Forms.Tests/RichTextBoxTargetTests.cs +++ b/NLog.Windows.Forms.Tests/RichTextBoxTargetTests.cs @@ -55,21 +55,32 @@ public void SimpleRichTextBoxTargetTest() var result = rtfText; Assert.Contains(@"{\colortbl ;\red255\green255\blue255;\red255\green0\blue0;\red255\green165\blue0;\red0\green0\blue0;\red128\green128\blue128;\red169\green169\blue169;}", result); +#if NETCOREAPP + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\b\f0\fs18 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); +#else if (IsAppVeyor()) { - Assert.Contains(@"\viewkind4\uc1\pard\cf1\highlight2\b\f0\fs17 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\b\f0\fs17 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); } else { - Assert.Contains(@"\viewkind4\uc1\pard\cf1\highlight2\b\f0\fs15 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\b\f0\fs15 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); } +#endif Assert.Contains(@"\cf2\highlight1\i Error NLog.UnitTests.Targets.RichTextBoxTargetTests Foo\par", result); Assert.Contains(@"\cf3\ul\b0\i0 Warn NLog.UnitTests.Targets.RichTextBoxTargetTests Bar\par", result); Assert.Contains(@"\cf4\ulnone Info NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); Assert.Contains(@"\cf5 Debug NLog.UnitTests.Targets.RichTextBoxTargetTests Foo\par", result); Assert.Contains(@"\cf6\i Trace NLog.UnitTests.Targets.RichTextBoxTargetTests Bar\par", result); +#if NETCOREAPP + Assert.Contains(@"\cf0\highlight0\i0\par", result); +#else Assert.Contains(@"\cf0\highlight0\i0\f1\par", result); +#endif Assert.Contains(@"}", result); LogManager.Configuration = null; @@ -115,7 +126,11 @@ public void NoColoringTest() Assert.Contains(@"Info NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); Assert.Contains(@"Debug NLog.UnitTests.Targets.RichTextBoxTargetTests Foo\par", result); Assert.Contains(@"Trace NLog.UnitTests.Targets.RichTextBoxTargetTests Bar\par", result); +#if NETCOREAPP + Assert.Contains(@"\cf0\highlight0\par", result); +#else Assert.Contains(@"\cf0\highlight0\f1\par", result); +#endif Assert.Contains(@"}", result); } finally @@ -166,7 +181,11 @@ public void CustomRowColoringTest() Assert.Contains(@"\cf1 Info NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); Assert.Contains(@"Debug NLog.UnitTests.Targets.RichTextBoxTargetTests Foo\par", result); Assert.Contains(@"\cf3 Trace NLog.UnitTests.Targets.RichTextBoxTargetTests Bar\par", result); +#if NETCOREAPP + Assert.Contains(@"\cf0\highlight0\par", result); +#else Assert.Contains(@"\cf0\highlight0\f1\par", result); +#endif Assert.Contains(@"}", result); } finally @@ -177,14 +196,21 @@ public void CustomRowColoringTest() private static void AssertViewkind(string result) { +#if NETCOREAPP + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\f0\fs18 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); +#else if (IsAppVeyor()) { - Assert.Contains(@"\viewkind4\uc1\pard\cf1\highlight2\f0\fs17 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\f0\fs17 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); } else { - Assert.Contains(@"\viewkind4\uc1\pard\cf1\highlight2\f0\fs15 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\f0\fs15 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test\par", result); } +#endif } [Fact] @@ -226,21 +252,32 @@ public void CustomWordRowColoringTest() var result = rtfText; Assert.Contains(@"{\colortbl ;\red0\green0\blue0;\red255\green255\blue255;\red255\green0\blue0;\red0\green128\blue0;}", result); +#if NETCOREAPP + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\f0\fs18 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test \cf3\f1 zzz\cf1\f0\par", result); +#else if (IsAppVeyor()) { - Assert.Contains(@"\viewkind4\uc1\pard\cf1\highlight2\f0\fs17 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test \cf3\f1 zzz\cf1\f0\par", result); + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\f0\fs17 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test \cf3\f1 zzz\cf1\f0\par", result); } else { - Assert.Contains(@"\viewkind4\uc1\pard\cf1\highlight2\f0\fs15 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test \cf3\f1 zzz\cf1\f0\par", result); + Assert.Contains(@"\viewkind4\uc1", result); + Assert.Contains(@"\pard\cf1\highlight2\f0\fs15 Fatal NLog.UnitTests.Targets.RichTextBoxTargetTests Test \cf3\f1 zzz\cf1\f0\par", result); } +#endif Assert.Contains(@"Error NLog.UnitTests.Targets.RichTextBoxTargetTests Foo xxx\par", result); Assert.Contains(@"Warn NLog.UnitTests.Targets.RichTextBoxTargetTests Bar yyy\par", result); Assert.Contains(@"Info NLog.UnitTests.Targets.RichTextBoxTargetTests Test \cf4\f1 aaa\cf1\f0\par", result); Assert.Contains(@"Debug NLog.UnitTests.Targets.RichTextBoxTargetTests Foo \cf3\f1 zzz\cf1\f0\par", result); Assert.Contains(@"Trace NLog.UnitTests.Targets.RichTextBoxTargetTests Bar ccc\par", result); +#if NETCOREAPP + Assert.Contains(@"\cf0\highlight0\par", result); +#else Assert.Contains(@"\cf0\highlight0\f1\par", result); +#endif Assert.Contains(@"}", result); } finally @@ -299,7 +336,6 @@ public void MaxLinesTest() { ControlName = "Control1", Layout = "${message}", - ShowMinimized = true, ToolWindow = false, AutoScroll = true, }; @@ -1006,6 +1042,8 @@ public void ManualRegisterTestWithRetentionConfigReload() } } +#if LINKS_SUPPORTED + [Fact] public void LinkLayoutTestDisabledLinks() { @@ -1029,6 +1067,7 @@ public void LinkLayoutTestDisabledLinks() Assert.Matches(@"(\([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}\))", result); //the placeholder GUID was not replaced by was not replaced because of SupportLinks set to false } + [Fact] public void LinkTest() { @@ -1054,9 +1093,14 @@ public void LinkTest() string resultText = target.TargetRichTextBox.Text; Assert.DoesNotMatch(@"(\([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}\))", resultRtf); //the placeholder GUID was replaced Assert.Contains("descr#link", resultText); //text contains visible and invisible parts +#if NETCOREAPP + Assert.Contains(@"{\field{\*\fldinst{HYPERLINK ""descr#link", resultRtf); //RTF contains everything +#else Assert.Contains(@"descr\v #link", resultRtf); //RTF contains everything +#endif } + [Fact] public void LinkTestConditional() { @@ -1084,7 +1128,11 @@ public void LinkTestConditional() string resultRtf = ExtractRtf(target.TargetRichTextBox); Assert.Contains("TestNoLink", resultText); Assert.DoesNotContain("#link", resultText); //no link for first event +#if NETCOREAPP + Assert.DoesNotContain(@"{\field{\*\fldinst{HYPERLINK", resultRtf); //no link for first event +#else Assert.DoesNotContain(@"\v #link", resultRtf); //no link for first event +#endif } @@ -1100,8 +1148,13 @@ public void LinkTestConditional() { string resultText = target.TargetRichTextBox.Text; string resultRtf = ExtractRtf(target.TargetRichTextBox); +#if NETCOREAPP + Assert.Contains("TestWithLink HYPERLINK \"marker_text#link", resultText); //link for a second event + Assert.Contains(@"TestWithLink {{\field{\*\fldinst{HYPERLINK ""marker_text#link", resultRtf); //link for a second event +#else Assert.Contains("TestWithLink marker_text#link", resultText); //link for a second event Assert.Contains(@"marker_text\v #link", resultRtf); //link for a second event +#endif } } @@ -1135,7 +1188,11 @@ public void LinkTestExcessLinksRemoved() string resultText = target.TargetRichTextBox.Text; string resultRtf = ExtractRtf(target.TargetRichTextBox); Assert.Contains("#link", resultText); //some links exist +#if NETCOREAPP + Assert.Contains(@"{\field{\*\fldinst{HYPERLINK", resultRtf); //some links exist +#else Assert.Contains(@"\v #link", resultRtf); //some links exist +#endif Assert.True(target.LinkedEventsCount == target.MaxLines); //storing 5, not 100 events } @@ -1165,9 +1222,13 @@ public void LinkClickTest() bool linkClickedFromHandler = false; string linkTextFromHandler = null; LogEventInfo logEventFromHandler = null; + var cancellationTokenSource = new CancellationTokenSource(); + var cancellationToken = cancellationTokenSource.Token; + RichTextBoxTarget.DelLinkClicked clickHandler = (RichTextBoxTarget sender, string linkText, LogEventInfo logEvent) => { + cancellationTokenSource.Cancel(); //actual checks moved to main code to make exceptions caught by the test runner. linkClickedFromHandler = true; linkTextFromHandler = linkText; @@ -1177,6 +1238,16 @@ public void LinkClickTest() RichTextBoxTarget.GetTargetByControl(target.TargetRichTextBox).LinkClicked += clickHandler; + Task.Run(() => + { + // max wait time. After that. Stop + int timeout = 1_000; + Thread.Sleep(timeout); + target.TargetForm.Close(); + throw new TimeoutException("Waited to long for click"); + + }, cancellationToken); + //simulate clicking on a link Task.Run(() => { @@ -1190,13 +1261,14 @@ public void LinkClickTest() } }); - //in case link does not click, this would hang up infinitely; + Application.Run(target.TargetForm); Assert.True(linkClickedFromHandler); //check that we have actually clicked on a link, not just missed anything Assert.True("link" == linkTextFromHandler); Assert.True("Test" == logEventFromHandler.Message); } +#endif #region mouse click smulation diff --git a/NLog.Windows.Forms.sln b/NLog.Windows.Forms.sln index e7cc002..3430edc 100644 --- a/NLog.Windows.Forms.sln +++ b/NLog.Windows.Forms.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.645 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29001.49 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Windows.Forms", "NLog.Windows.Forms\NLog.Windows.Forms.csproj", "{EB5C7E87-C5F4-43FC-AC71-BE0A22F5B932}" EndProject @@ -9,6 +9,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Windows.Forms.Tests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication", "TestApplication\TestApplication.csproj", "{03D9D89A-B972-4446-AB4A-A430851243D0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplicationCore3", "TestApplicationCore3\TestApplicationCore3.csproj", "{9FAC81DA-0137-47E9-957A-D8A9A5215338}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplicationNet5", "TestApplicationNet5\TestApplicationNet5.csproj", "{134980CC-0226-42B1-B02F-A9C81AAB0A3D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test Applications", "Test Applications", "{6AB4C95A-36D8-4F52-8F25-EF9CA98AF536}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,10 +33,23 @@ Global {03D9D89A-B972-4446-AB4A-A430851243D0}.Debug|Any CPU.Build.0 = Debug|Any CPU {03D9D89A-B972-4446-AB4A-A430851243D0}.Release|Any CPU.ActiveCfg = Release|Any CPU {03D9D89A-B972-4446-AB4A-A430851243D0}.Release|Any CPU.Build.0 = Release|Any CPU + {9FAC81DA-0137-47E9-957A-D8A9A5215338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FAC81DA-0137-47E9-957A-D8A9A5215338}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FAC81DA-0137-47E9-957A-D8A9A5215338}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FAC81DA-0137-47E9-957A-D8A9A5215338}.Release|Any CPU.Build.0 = Release|Any CPU + {134980CC-0226-42B1-B02F-A9C81AAB0A3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {134980CC-0226-42B1-B02F-A9C81AAB0A3D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {134980CC-0226-42B1-B02F-A9C81AAB0A3D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {134980CC-0226-42B1-B02F-A9C81AAB0A3D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {03D9D89A-B972-4446-AB4A-A430851243D0} = {6AB4C95A-36D8-4F52-8F25-EF9CA98AF536} + {9FAC81DA-0137-47E9-957A-D8A9A5215338} = {6AB4C95A-36D8-4F52-8F25-EF9CA98AF536} + {134980CC-0226-42B1-B02F-A9C81AAB0A3D} = {6AB4C95A-36D8-4F52-8F25-EF9CA98AF536} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2DC4C500-52F1-4D06-863D-209D713D03ED} EndGlobalSection diff --git a/NLog.Windows.Forms/FormHelper.cs b/NLog.Windows.Forms/FormHelper.cs index 6e149e0..8c00680 100644 --- a/NLog.Windows.Forms/FormHelper.cs +++ b/NLog.Windows.Forms/FormHelper.cs @@ -108,7 +108,7 @@ internal static Form CreateForm(string name, int width, int height, bool show, b { Name = name, Text = "NLog", - Icon = GetNLogIcon() + Icon = GetNLogIcon(), }; #if !Smartphone @@ -163,6 +163,9 @@ private static Icon GetNLogIcon() /// internal static void ChangeSelectionToLink(RichTextBox textBox, string text, string hyperlink) { +#if NETCOREAPP + textBox.SelectedRtf = @"{\rtf1\ansi{\field{\*\fldinst{HYPERLINK """ + text + @"#" + hyperlink + @""" }}{\fldrslt{" + text + @"}}}}"; +#else int selectionStart = textBox.SelectionStart; //using \v tag to hide hyperlink part of the text, and \v0 to end hiding. See http://stackoverflow.com/a/14339531/376066 @@ -171,6 +174,7 @@ internal static void ChangeSelectionToLink(RichTextBox textBox, string text, str textBox.Select(selectionStart, text.Length + 1 + hyperlink.Length); //now select both visible and invisible part SetSelectionStyle(textBox, CFM_LINK, CFE_LINK); //and turn into a link +#endif } /// diff --git a/NLog.Windows.Forms/NLog.Windows.Forms.csproj b/NLog.Windows.Forms/NLog.Windows.Forms.csproj index 70bdc5c..489fb70 100644 --- a/NLog.Windows.Forms/NLog.Windows.Forms.csproj +++ b/NLog.Windows.Forms/NLog.Windows.Forms.csproj @@ -1,6 +1,6 @@ - + - net35 + net35;netcoreapp3.1;net5.0-windows NLog.Windows.Forms NLog NLog.Windows.Forms @@ -16,6 +16,7 @@ true true Full + true true NLog.snk true @@ -23,19 +24,17 @@ https://github.com/NLog/NLog.Windows.Forms.git git 4.0.0.0 - - -- RichTextBoxTarget: added overloads for ReInitializeAllTextboxes and GetTargetByControl (#72) (@304NotModified) -- RichTextBoxTarget: better error handling for empty or unexpected NLog configs (#72) (@304NotModified) - -- Update NLog to 4.7.9 (#74) (@304NotModified) -- Fixed publishing Symbol package (#46) (@304NotModified) -- Added Sourcelink (#70) (@304NotModified) -- Enable deterministic build (#73) (@304NotModified) + +Added support for .NET Core 3.1 and .NET 5 (#42) (@weltkante, @304NotModified) + + - + + + $(DefineConstants);LINKS_SUPPORTED + diff --git a/NLog.Windows.Forms/RichTextBoxLinkLayoutRenderer .cs b/NLog.Windows.Forms/RichTextBoxLinkLayoutRenderer .cs index 53d2f09..6133eba 100644 --- a/NLog.Windows.Forms/RichTextBoxLinkLayoutRenderer .cs +++ b/NLog.Windows.Forms/RichTextBoxLinkLayoutRenderer .cs @@ -9,6 +9,8 @@ namespace NLog.Windows.Forms { +#if LINKS_SUPPORTED + /// /// Strings rendered with this rendrer would convert to links in the control. /// @@ -92,4 +94,5 @@ internal string GetValue(string guid) } } } +#endif } diff --git a/NLog.Windows.Forms/RichTextBoxTarget.cs b/NLog.Windows.Forms/RichTextBoxTarget.cs index c65b37e..625df3c 100644 --- a/NLog.Windows.Forms/RichTextBoxTarget.cs +++ b/NLog.Windows.Forms/RichTextBoxTarget.cs @@ -363,6 +363,9 @@ public RichTextBoxTargetMessageRetentionStrategy MessageRetention /// private volatile Queue messageQueue; + +#if LINKS_SUPPORTED + /// /// If set to true, using "rtb-link" renderer () would create clickable links in the control. /// @@ -380,7 +383,11 @@ public bool SupportLinks if (linkAddRegex == null) { linkAddRegex = new Regex(@"(\([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}\))", RegexOptions.Compiled); +#if NETCOREAPP + linkRemoveRtfRegex = new Regex(@"\{\\field\{\\\*\\fldinst\{HYPERLINK ""[^""]*\#" + LinkPrefix + @"(\d+)"" \}\}", RegexOptions.Compiled); +#else linkRemoveRtfRegex = new Regex(@"\\v #" + LinkPrefix + @"(\d+)\\v0", RegexOptions.Compiled); +#endif } } lock (linkedEventsLock) @@ -396,6 +403,8 @@ public bool SupportLinks } } +#endif +#if LINKS_SUPPORTED /// /// Type of delegate for event. /// @@ -409,7 +418,7 @@ public bool SupportLinks /// /// public event DelLinkClicked LinkClicked; - + /// /// Actual value of the property /// @@ -425,6 +434,7 @@ public bool SupportLinks /// private Dictionary linkedEvents; + /// /// Returns number of events stored for active links in the control. /// Used only in tests to check that non needed events are removed. @@ -444,6 +454,8 @@ internal int? LinkedEventsCount } } + + /// /// Internal prefix that is added to the link id in RTF /// @@ -465,7 +477,7 @@ internal int? LinkedEventsCount /// Lazily initialized in .set(true). Assure checking before accessing the field /// private static Regex linkRemoveRtfRegex; - +#endif /// /// Initializes the target. Can be used by inheriting classes @@ -598,12 +610,16 @@ private void AttachToControl(Form form, RichTextBox textboxControl) this.TargetForm = form; this.TargetRichTextBox = textboxControl; +#if LINKS_SUPPORTED + if (this.SupportLinks) { this.TargetRichTextBox.DetectUrls = false; this.TargetRichTextBox.LinkClicked += TargetRichTextBox_LinkClicked; } +#endif + //OnReattach? switch (messageRetention) { @@ -637,6 +653,8 @@ private void AttachToControl(Form form, RichTextBox textboxControl) } } +#if LINKS_SUPPORTED + /// /// Attached to RTB-control's LinkClicked event to convert link text to logEvent /// @@ -679,6 +697,8 @@ private void TargetRichTextBox_LinkClicked(object sender, LinkClickedEventArgs e } } +#endif + /// /// if is true, then destroys created form. Resets , and to default values /// @@ -881,6 +901,8 @@ private void SendTheMessageToRichTextBox(string logMessage, RichTextBoxRowColori } } +#if LINKS_SUPPORTED + if (SupportLinks) { object linkInfoObj; @@ -917,6 +939,9 @@ private void SendTheMessageToRichTextBox(string logMessage, RichTextBoxRowColori } } +#endif + + //remove some lines if there above the max if (MaxLines > 0) { @@ -931,6 +956,7 @@ private void SendTheMessageToRichTextBox(string logMessage, RichTextBoxRowColori { textBox.SelectionStart = 0; textBox.SelectionLength = textBox.GetFirstCharIndexFromLine(tooManyLines); +#if LINKS_SUPPORTED if (SupportLinks) { string selectedRtf = textBox.SelectedRtf; @@ -947,6 +973,7 @@ private void SendTheMessageToRichTextBox(string logMessage, RichTextBoxRowColori } } } +#endif textBox.SelectedRtf = "{\\rtf1\\ansi}"; } } diff --git a/TestApplication/Form1.cs b/TestApplication/Form1.cs index de1096a..1a5981e 100644 --- a/TestApplication/Form1.cs +++ b/TestApplication/Form1.cs @@ -24,6 +24,13 @@ public Form1() Logger.Info("Init"); RichTextBoxTarget.ReInitializeAllTextboxes(this); + + Logger.Log(LogLevel.Trace, "Log Trace"); + Logger.Log(LogLevel.Debug, "Log Debug"); + Logger.Log(LogLevel.Info, "Log Info"); + Logger.Log(LogLevel.Warn, "Log Warn"); + Logger.Log(LogLevel.Error, "Log Error"); + Logger.Log(LogLevel.Fatal, "Log Fatal"); var thread = new Thread(() => { diff --git a/TestApplication/Program.cs b/TestApplication/Program.cs index 582dea0..bb5e548 100644 --- a/TestApplication/Program.cs +++ b/TestApplication/Program.cs @@ -1,31 +1,20 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; -using NLog; namespace TestApplication { static class Program { - - /// /// The main entry point for the application. /// [STAThread] static void Main() { - - Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); - - - } } } diff --git a/TestApplication/nlog.config b/TestApplication/nlog.config index ebe436e..592ec4a 100644 --- a/TestApplication/nlog.config +++ b/TestApplication/nlog.config @@ -13,7 +13,7 @@ layout="${message}" autoScroll="true" - maxLines="10" + maxLines="30" useDefaultRowColoringRules="true" /> @@ -24,7 +24,7 @@ formName="Form1" ControlName="richTextBox1" autoScroll="true" - maxLines="20" + maxLines="30" allowAccessoryFormCreation="false" messageRetention="OnlyMissed" @@ -40,7 +40,7 @@ formName="Form1" ControlName="richTextBox2" autoScroll="true" - maxLines="20" + maxLines="30" allowAccessoryFormCreation="false" messageRetention="OnlyMissed" @@ -65,7 +65,7 @@ - + \ No newline at end of file diff --git a/TestApplicationCore3/Form1.Designer.cs b/TestApplicationCore3/Form1.Designer.cs new file mode 100644 index 0000000..e23810b --- /dev/null +++ b/TestApplicationCore3/Form1.Designer.cs @@ -0,0 +1,86 @@ +namespace TestApplicationCore3 +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.fileSystemWatcher1 = new System.IO.FileSystemWatcher(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.richTextBox2 = new System.Windows.Forms.RichTextBox(); + ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).BeginInit(); + this.SuspendLayout(); + // + // fileSystemWatcher1 + // + this.fileSystemWatcher1.EnableRaisingEvents = true; + this.fileSystemWatcher1.SynchronizingObject = this; + // + // richTextBox1 + // + this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.richTextBox1.Location = new System.Drawing.Point(12, 12); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(320, 287); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + // + // richTextBox2 + // + this.richTextBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.richTextBox2.Location = new System.Drawing.Point(338, 12); + this.richTextBox2.Name = "richTextBox2"; + this.richTextBox2.Size = new System.Drawing.Size(320, 287); + this.richTextBox2.TabIndex = 1; + this.richTextBox2.Text = ""; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(671, 311); + this.Controls.Add(this.richTextBox2); + this.Controls.Add(this.richTextBox1); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.IO.FileSystemWatcher fileSystemWatcher1; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.RichTextBox richTextBox2; + } +} + diff --git a/TestApplicationCore3/Form1.cs b/TestApplicationCore3/Form1.cs new file mode 100644 index 0000000..b7477dd --- /dev/null +++ b/TestApplicationCore3/Form1.cs @@ -0,0 +1,48 @@ +using System; +using System.Linq; +using System.Threading; +using System.Windows.Forms; +using NLog; +using NLog.Windows.Forms; + +namespace TestApplicationCore3 +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + + NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); + Logger.Info("Init"); + + RichTextBoxTarget.ReInitializeAllTextboxes(this); + + Logger.Log(LogLevel.Trace, "Log Trace"); + Logger.Log(LogLevel.Debug, "Log Debug"); + Logger.Log(LogLevel.Info, "Log Info"); + Logger.Log(LogLevel.Warn, "Log Warn"); + Logger.Log(LogLevel.Error, "Log Error"); + Logger.Log(LogLevel.Fatal, "Log Fatal"); + + var thread = new Thread(() => + { + Random rnd = new Random(); + for (int i = 0; i < 10; i++) + { + LogEventInfo theEvent = new LogEventInfo(LogLevel.Debug, "", i + ": a line with some length\n a new line"); + Logger.Log(theEvent); + Thread.Sleep(200); + } + Logger.Info("Done"); + }); + Logger.Info("start thread"); + thread.Start(); + + } + + private void Form1_Load(object sender, EventArgs e) + { + } + } +} diff --git a/TestApplicationCore3/Form1.resx b/TestApplicationCore3/Form1.resx new file mode 100644 index 0000000..fc531d8 --- /dev/null +++ b/TestApplicationCore3/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/TestApplicationCore3/NLog.xsd b/TestApplicationCore3/NLog.xsd new file mode 100644 index 0000000..85019de --- /dev/null +++ b/TestApplicationCore3/NLog.xsd @@ -0,0 +1,2479 @@ + + + + + + + + + + + + + + + Watch config file for changes and reload automatically. + + + + + Print internal NLog messages to the console. Default value is: false + + + + + Print internal NLog messages to the console error output. Default value is: false + + + + + Write internal NLog messages to the specified file. + + + + + Log level threshold for internal log messages. Default value is: Info. + + + + + Global log level threshold for application log messages. Messages below this level won't be logged.. + + + + + Pass NLog internal exceptions to the application. Default value is: false. + + + + + + + + + + + + + + Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). + + + + + + + + + + + + + + + + + Prefix for targets/layout renderers/filters/conditions loaded from this assembly. + + + + + Load NLog extensions from the specified file (*.dll) + + + + + Load NLog extensions from the specified assembly. Assembly name should be fully qualified. + + + + + + + + + + Name of the logger. May include '*' character which acts like a wildcard. Allowed forms are: *, Name, *Name, Name* and *Name* + + + + + Comma separated list of levels that this rule matches. + + + + + Minimum level that this rule matches. + + + + + Maximum level that this rule matches. + + + + + Level that this rule matches. + + + + + Comma separated list of target names. + + + + + Ignore further rules if this one matches. + + + + + Enable or disable logging rule. Disabled rules are ignored. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the file to be included. The name is relative to the name of the current config file. + + + + + Ignore any errors in the include file. + + + + + + + Variable name. + + + + + Variable value. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to add <!-- --> comments around all written texts. + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events that should be processed in a batch by the lazy writer thread. + + + + + Action to be taken when the lazy writer thread request queue count exceeds the set limit. + + + + + Limit on the number of requests in the lazy writer thread request queue. + + + + + Time in milliseconds to sleep between batches. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events to be buffered. + + + + + Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. + + + + + Indicates whether to use sliding timeout. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Network address. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Viewer parameter name. + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to use default row highlighting rules. + + + + + The encoding for writing messages to the . + + + + + Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Condition that must be met in order to set the specified foreground and background color. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + Indicates whether to ignore case when comparing texts. + + + + + Regular expression to be matched. You must specify either text or regex. + + + + + Text to be matched. You must specify either text or regex. + + + + + Indicates whether to match whole words only. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send the log messages to the standard error instead of the standard output. + + + + + The encoding for writing messages to the . + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. + + + + + Name of the connection string (as specified in <connectionStrings> configuration section. + + + + + Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. + + + + + Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. + + + + + Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. + + + + + Name of the database provider. + + + + + Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. + + + + + Indicates whether to keep the database connection open between the log events. + + + + + Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. + + + + + Text of the SQL command to be run on each log level. + + + + + Type of the SQL command to be run on each log level. + + + + + + + + + + + + + + + + + + + + + + + Type of the command. + + + + + Connection string to run the command against. If not provided, connection string from the target is used. + + + + + Indicates whether to ignore failures. + + + + + Command text. + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Database parameter name. + + + + + Database parameter precision. + + + + + Database parameter scale. + + + + + Database parameter size. + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Layout that renders event Category. + + + + + Layout that renders event ID. + + + + + Name of the Event Log to write to. This can be System, Application or any user-defined name. + + + + + Name of the machine on which Event Log service is running. + + + + + Value to be used as the event Source. + + + + + Optional entrytype. When not set, or when not convertable to then determined by + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether to return to the first target after any successful write. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + File encoding. + + + + + Line ending mode. + + + + + Maximum number of archive files that should be kept. + + + + + Way file archives are numbered. + + + + + Name of the file to be used for an archive. + + + + + Indicates whether to automatically archive log files every time the specified time passes. + + + + + Size in bytes above which log files will be automatically archived. + + + + + Indicates whether to compress archive files into the zip archive format. + + + + + Gets ors set a value indicating whether a managed file stream is forced, instead of used the native implementation. + + + + + File attributes (Windows only). + + + + + Indicates whether to replace file contents on each write instead of appending log message at the end. + + + + + Name of the file to write to. + + + + + Value specifying the date format to use when archving files. + + + + + Indicates whether to archive old log file on startup. + + + + + Indicates whether to create directories if they do not exist. + + + + + Indicates whether to delete old log file on startup. + + + + + Indicates whether to enable log file(s) to be deleted. + + + + + Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity. + + + + + Indicates whether concurrent writes to the log file by multiple processes on different network hosts. + + + + + Maximum number of log filenames that should be stored as existing. + + + + + Indicates whether to keep log file open instead of opening and closing it on each logging event. + + + + + Indicates whether concurrent writes to the log file by multiple processes on the same host. + + + + + Number of times the write is appended on the file before NLog discards the log message. + + + + + Delay in milliseconds to wait before attempting to write to the file again. + + + + + Indicates whether to automatically flush the file buffers after each log message. + + + + + Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). + + + + + Log file buffer size in bytes. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Condition expression. Log events who meet this condition will be forwarded to the wrapped target. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Windows domain name to change context to. + + + + + Required impersonation level. + + + + + Type of the logon provider. + + + + + Logon Type. + + + + + User account password. + + + + + Indicates whether to revert to the credentials of the process instead of impersonating another user. + + + + + Username to change context to. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Endpoint address. + + + + + Name of the endpoint configuration in WCF configuration file. + + + + + Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply) + + + + + Client ID. + + + + + Indicates whether to include per-event properties in the payload sent to the server. + + + + + Indicates whether to use binary message encoding. + + + + + + + + + + + + + + Layout that should be use to calculate the value for the parameter. + + + + + Name of the parameter. + + + + + Type of the parameter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send message as HTML instead of plain text. + + + + + Encoding to be used for sending e-mail. + + + + + Indicates whether to add new lines between log entries. + + + + + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Mail message body (repeated for each log message send in one mail). + + + + + Mail subject. + + + + + Sender's email address (e.g. joe@domain.com). + + + + + Indicates whether NewLine characters in the body should be replaced with tags. + + + + + Priority used for sending mails. + + + + + Indicates the SMTP client timeout. + + + + + SMTP Server to be used for sending. + + + + + SMTP Authentication mode. + + + + + Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. + + + + + Port number that SMTP Server is listening on. + + + + + Indicates whether the default Settings from System.Net.MailSettings should be used. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used when writing text to the queue. + + + + + Indicates whether to use the XML format when serializing message. This will also disable creating queues. + + + + + Indicates whether to check if a queue exists before writing to it. + + + + + Indicates whether to create the queue if it doesn't exists. + + + + + Label to associate with each message. + + + + + Name of the queue to write to. + + + + + Indicates whether to use recoverable messages (with guaranteed delivery). + + + + + + + + + + + + + + + + + Name of the target. + + + + + Class name. + + + + + Method name. The method must be public and static. + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Network address. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Network address. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to perform layout calculation. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether performance counter should be automatically created. + + + + + Name of the performance counter category. + + + + + Counter help text. + + + + + Name of the performance counter. + + + + + Performance counter type. + + + + + Performance counter instance name. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Default filter to be applied when no specific rule matches. + + + + + + + + + + + + + Condition to be tested. + + + + + Resulting filter to be applied when the condition matches. + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Number of times to repeat each log message. + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of retries that should be attempted on the wrapped target in case of a failure. + + + + + Time to wait between retries in milliseconds. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8. + + + + + Encoding. + + + + + Web service method name. Only used with Soap. + + + + + Web service namespace. Only used with Soap. + + + + + Protocol to be used when calling web service. + + + + + Web service URL. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). + + + + + Column delimiter. + + + + + Quote Character. + + + + + Quoting mode. + + + + + Indicates whether CVS should include header. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Layout of the column. + + + + + Name of the column. + + + + + + + + + + + + + + + + + + + + Layout that will be rendered as the attribute's value. + + + + + Name of the attribute. + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + + + + + + + + + + + + + + + + + Layout text. + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Condition expression. + + + + + + + + + + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TestApplicationCore3/Program.cs b/TestApplicationCore3/Program.cs new file mode 100644 index 0000000..7e2bbdc --- /dev/null +++ b/TestApplicationCore3/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; +using System.Windows.Forms; + +namespace TestApplicationCore3 +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/TestApplicationCore3/TestApplicationCore3.csproj b/TestApplicationCore3/TestApplicationCore3.csproj new file mode 100644 index 0000000..7fa5f66 --- /dev/null +++ b/TestApplicationCore3/TestApplicationCore3.csproj @@ -0,0 +1,34 @@ + + + + WinExe + netcoreapp3.1 + true + + + + + + + + + Form + + + Form1.cs + + + + + + Form1.cs + + + + + + PreserveNewest + + + + \ No newline at end of file diff --git a/TestApplicationCore3/nlog.config b/TestApplicationCore3/nlog.config new file mode 100644 index 0000000..b304652 --- /dev/null +++ b/TestApplicationCore3/nlog.config @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TestApplicationNet5/Form1.Designer.cs b/TestApplicationNet5/Form1.Designer.cs new file mode 100644 index 0000000..e23810b --- /dev/null +++ b/TestApplicationNet5/Form1.Designer.cs @@ -0,0 +1,86 @@ +namespace TestApplicationCore3 +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.fileSystemWatcher1 = new System.IO.FileSystemWatcher(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.richTextBox2 = new System.Windows.Forms.RichTextBox(); + ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).BeginInit(); + this.SuspendLayout(); + // + // fileSystemWatcher1 + // + this.fileSystemWatcher1.EnableRaisingEvents = true; + this.fileSystemWatcher1.SynchronizingObject = this; + // + // richTextBox1 + // + this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.richTextBox1.Location = new System.Drawing.Point(12, 12); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(320, 287); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + // + // richTextBox2 + // + this.richTextBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.richTextBox2.Location = new System.Drawing.Point(338, 12); + this.richTextBox2.Name = "richTextBox2"; + this.richTextBox2.Size = new System.Drawing.Size(320, 287); + this.richTextBox2.TabIndex = 1; + this.richTextBox2.Text = ""; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(671, 311); + this.Controls.Add(this.richTextBox2); + this.Controls.Add(this.richTextBox1); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.IO.FileSystemWatcher fileSystemWatcher1; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.RichTextBox richTextBox2; + } +} + diff --git a/TestApplicationNet5/Form1.cs b/TestApplicationNet5/Form1.cs new file mode 100644 index 0000000..e827013 --- /dev/null +++ b/TestApplicationNet5/Form1.cs @@ -0,0 +1,75 @@ +using System; +using System.Linq; +using System.Threading; +using System.Windows.Forms; +using NLog; +using NLog.Windows.Forms; + +namespace TestApplicationCore3 +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + + NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); + Logger.Info("Init"); + + RichTextBoxTarget.ReInitializeAllTextboxes(this); + + Logger.Log(LogLevel.Trace, "Log Trace"); + Logger.Log(LogLevel.Debug, "Log Debug"); + Logger.Log(LogLevel.Info, "Log Info"); + Logger.Log(LogLevel.Warn, "Log Warn"); + Logger.Log(LogLevel.Error, "Log Error"); + Logger.Log(LogLevel.Fatal, "Log Fatal"); + + var thread = new Thread(() => + { + Random rnd = new Random(); + for (int i = 0; i < 10; i++) + { + LogEventInfo theEvent = new LogEventInfo(LogLevel.Debug, "", i + ": a line with some length\n a new line"); + if (rnd.NextDouble() > 0.1) + { + theEvent.Properties["ShowLink"] = "link via property"; + } + if (rnd.NextDouble() > 0.5) + { + theEvent.Properties["ShowLink2"] = "Another link"; + } + Logger.Log(theEvent); + Thread.Sleep(200); + } + Logger.Info("Done"); + }); + Logger.Info("start thread"); + thread.Start(); + + } + + private void Form1_Load(object sender, EventArgs e) + { + RichTextBoxTarget.GetTargetByControl(richTextBox1).LinkClicked += Form1_LinkClicked; + RichTextBoxTarget.GetTargetByControl(richTextBox2).LinkClicked += Form1_LinkClicked; + } + + private void Form1_LinkClicked(RichTextBoxTarget sender, string linkText, LogEventInfo logEvent) + { + //COM HRESULT E_FAIL happens when not used BeginInvoke and links are clicked while spinning + BeginInvokeLambda(this, + () => { MessageBox.Show("Clicked link '" + linkText + "' for event\n" + logEvent, sender.Name); } + ); + } + + private static IAsyncResult BeginInvokeLambda(Control control, Action action) + { + if (!control.IsDisposed) + { + return control.BeginInvoke(action, null); + } + return null; + } + } +} diff --git a/TestApplicationNet5/Form1.resx b/TestApplicationNet5/Form1.resx new file mode 100644 index 0000000..fc531d8 --- /dev/null +++ b/TestApplicationNet5/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/TestApplicationNet5/NLog.xsd b/TestApplicationNet5/NLog.xsd new file mode 100644 index 0000000..85019de --- /dev/null +++ b/TestApplicationNet5/NLog.xsd @@ -0,0 +1,2479 @@ + + + + + + + + + + + + + + + Watch config file for changes and reload automatically. + + + + + Print internal NLog messages to the console. Default value is: false + + + + + Print internal NLog messages to the console error output. Default value is: false + + + + + Write internal NLog messages to the specified file. + + + + + Log level threshold for internal log messages. Default value is: Info. + + + + + Global log level threshold for application log messages. Messages below this level won't be logged.. + + + + + Pass NLog internal exceptions to the application. Default value is: false. + + + + + + + + + + + + + + Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). + + + + + + + + + + + + + + + + + Prefix for targets/layout renderers/filters/conditions loaded from this assembly. + + + + + Load NLog extensions from the specified file (*.dll) + + + + + Load NLog extensions from the specified assembly. Assembly name should be fully qualified. + + + + + + + + + + Name of the logger. May include '*' character which acts like a wildcard. Allowed forms are: *, Name, *Name, Name* and *Name* + + + + + Comma separated list of levels that this rule matches. + + + + + Minimum level that this rule matches. + + + + + Maximum level that this rule matches. + + + + + Level that this rule matches. + + + + + Comma separated list of target names. + + + + + Ignore further rules if this one matches. + + + + + Enable or disable logging rule. Disabled rules are ignored. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the file to be included. The name is relative to the name of the current config file. + + + + + Ignore any errors in the include file. + + + + + + + Variable name. + + + + + Variable value. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to add <!-- --> comments around all written texts. + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events that should be processed in a batch by the lazy writer thread. + + + + + Action to be taken when the lazy writer thread request queue count exceeds the set limit. + + + + + Limit on the number of requests in the lazy writer thread request queue. + + + + + Time in milliseconds to sleep between batches. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events to be buffered. + + + + + Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. + + + + + Indicates whether to use sliding timeout. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Network address. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Viewer parameter name. + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to use default row highlighting rules. + + + + + The encoding for writing messages to the . + + + + + Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Condition that must be met in order to set the specified foreground and background color. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + Indicates whether to ignore case when comparing texts. + + + + + Regular expression to be matched. You must specify either text or regex. + + + + + Text to be matched. You must specify either text or regex. + + + + + Indicates whether to match whole words only. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send the log messages to the standard error instead of the standard output. + + + + + The encoding for writing messages to the . + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. + + + + + Name of the connection string (as specified in <connectionStrings> configuration section. + + + + + Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. + + + + + Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. + + + + + Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. + + + + + Name of the database provider. + + + + + Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. + + + + + Indicates whether to keep the database connection open between the log events. + + + + + Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. + + + + + Text of the SQL command to be run on each log level. + + + + + Type of the SQL command to be run on each log level. + + + + + + + + + + + + + + + + + + + + + + + Type of the command. + + + + + Connection string to run the command against. If not provided, connection string from the target is used. + + + + + Indicates whether to ignore failures. + + + + + Command text. + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Database parameter name. + + + + + Database parameter precision. + + + + + Database parameter scale. + + + + + Database parameter size. + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Layout that renders event Category. + + + + + Layout that renders event ID. + + + + + Name of the Event Log to write to. This can be System, Application or any user-defined name. + + + + + Name of the machine on which Event Log service is running. + + + + + Value to be used as the event Source. + + + + + Optional entrytype. When not set, or when not convertable to then determined by + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether to return to the first target after any successful write. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + File encoding. + + + + + Line ending mode. + + + + + Maximum number of archive files that should be kept. + + + + + Way file archives are numbered. + + + + + Name of the file to be used for an archive. + + + + + Indicates whether to automatically archive log files every time the specified time passes. + + + + + Size in bytes above which log files will be automatically archived. + + + + + Indicates whether to compress archive files into the zip archive format. + + + + + Gets ors set a value indicating whether a managed file stream is forced, instead of used the native implementation. + + + + + File attributes (Windows only). + + + + + Indicates whether to replace file contents on each write instead of appending log message at the end. + + + + + Name of the file to write to. + + + + + Value specifying the date format to use when archving files. + + + + + Indicates whether to archive old log file on startup. + + + + + Indicates whether to create directories if they do not exist. + + + + + Indicates whether to delete old log file on startup. + + + + + Indicates whether to enable log file(s) to be deleted. + + + + + Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity. + + + + + Indicates whether concurrent writes to the log file by multiple processes on different network hosts. + + + + + Maximum number of log filenames that should be stored as existing. + + + + + Indicates whether to keep log file open instead of opening and closing it on each logging event. + + + + + Indicates whether concurrent writes to the log file by multiple processes on the same host. + + + + + Number of times the write is appended on the file before NLog discards the log message. + + + + + Delay in milliseconds to wait before attempting to write to the file again. + + + + + Indicates whether to automatically flush the file buffers after each log message. + + + + + Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). + + + + + Log file buffer size in bytes. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Condition expression. Log events who meet this condition will be forwarded to the wrapped target. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Windows domain name to change context to. + + + + + Required impersonation level. + + + + + Type of the logon provider. + + + + + Logon Type. + + + + + User account password. + + + + + Indicates whether to revert to the credentials of the process instead of impersonating another user. + + + + + Username to change context to. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Endpoint address. + + + + + Name of the endpoint configuration in WCF configuration file. + + + + + Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply) + + + + + Client ID. + + + + + Indicates whether to include per-event properties in the payload sent to the server. + + + + + Indicates whether to use binary message encoding. + + + + + + + + + + + + + + Layout that should be use to calculate the value for the parameter. + + + + + Name of the parameter. + + + + + Type of the parameter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send message as HTML instead of plain text. + + + + + Encoding to be used for sending e-mail. + + + + + Indicates whether to add new lines between log entries. + + + + + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Mail message body (repeated for each log message send in one mail). + + + + + Mail subject. + + + + + Sender's email address (e.g. joe@domain.com). + + + + + Indicates whether NewLine characters in the body should be replaced with tags. + + + + + Priority used for sending mails. + + + + + Indicates the SMTP client timeout. + + + + + SMTP Server to be used for sending. + + + + + SMTP Authentication mode. + + + + + Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. + + + + + Port number that SMTP Server is listening on. + + + + + Indicates whether the default Settings from System.Net.MailSettings should be used. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used when writing text to the queue. + + + + + Indicates whether to use the XML format when serializing message. This will also disable creating queues. + + + + + Indicates whether to check if a queue exists before writing to it. + + + + + Indicates whether to create the queue if it doesn't exists. + + + + + Label to associate with each message. + + + + + Name of the queue to write to. + + + + + Indicates whether to use recoverable messages (with guaranteed delivery). + + + + + + + + + + + + + + + + + Name of the target. + + + + + Class name. + + + + + Method name. The method must be public and static. + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Network address. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Network address. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum queue size. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to perform layout calculation. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether performance counter should be automatically created. + + + + + Name of the performance counter category. + + + + + Counter help text. + + + + + Name of the performance counter. + + + + + Performance counter type. + + + + + Performance counter instance name. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Default filter to be applied when no specific rule matches. + + + + + + + + + + + + + Condition to be tested. + + + + + Resulting filter to be applied when the condition matches. + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Number of times to repeat each log message. + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of retries that should be attempted on the wrapped target in case of a failure. + + + + + Time to wait between retries in milliseconds. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8. + + + + + Encoding. + + + + + Web service method name. Only used with Soap. + + + + + Web service namespace. Only used with Soap. + + + + + Protocol to be used when calling web service. + + + + + Web service URL. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). + + + + + Column delimiter. + + + + + Quote Character. + + + + + Quoting mode. + + + + + Indicates whether CVS should include header. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Layout of the column. + + + + + Name of the column. + + + + + + + + + + + + + + + + + + + + Layout that will be rendered as the attribute's value. + + + + + Name of the attribute. + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + + + + + + + + + + + + + + + + + Layout text. + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Condition expression. + + + + + + + + + + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TestApplicationNet5/Program.cs b/TestApplicationNet5/Program.cs new file mode 100644 index 0000000..7e2bbdc --- /dev/null +++ b/TestApplicationNet5/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; +using System.Windows.Forms; + +namespace TestApplicationCore3 +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/TestApplicationNet5/TestApplicationNet5.csproj b/TestApplicationNet5/TestApplicationNet5.csproj new file mode 100644 index 0000000..87f148c --- /dev/null +++ b/TestApplicationNet5/TestApplicationNet5.csproj @@ -0,0 +1,34 @@ + + + + WinExe + net5.0-windows + true + + + + + + + + + Form + + + Form1.cs + + + + + + Form1.cs + + + + + + PreserveNewest + + + + \ No newline at end of file diff --git a/TestApplicationNet5/nlog.config b/TestApplicationNet5/nlog.config new file mode 100644 index 0000000..edd50bf --- /dev/null +++ b/TestApplicationNet5/nlog.config @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index de946c6..4a362fc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 4.4.0.{build} +version: 4.5.0.{build} image: Visual Studio 2019 clone_folder: c:\projects\nlog configuration: Release @@ -7,9 +7,10 @@ skip_tags: true build_script: - ps: .\build.ps1 test_script: - - nuget.exe install OpenCover -ExcludeVersion - - OpenCover\tools\OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:"\"c:\projects\nlog\NLog.Windows.Forms.Tests\bin\Release\net452\NLog.Windows.Forms.Tests.dll\" -appveyor -noshadow" -returntargetcode -filter:"+[NLog.Windows.Forms]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -output:coverage.xml - - "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%" + - nuget.exe install OpenCover -ExcludeVersion -DependencyVersion Ignore + - OpenCover\tools\OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:"\"c:\projects\nlog\NLog.Windows.Forms.Tests\bin\Release\net452\NLog.Windows.Forms.Tests.dll\" -appveyor -noshadow" -returntargetcode -filter:"+[NLog.Windows.Forms]* -[NLog.Windows.Forms.Tests]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -output:coverage.xml + - OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp3.1 -c debug NLog.Windows.Forms.Tests" -filter:"+[NLog.Windows.Forms]* -[NLog.Windows.Forms.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"NLog.Windows.Forms.Tests" + - OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net5.0 -c debug NLog.Windows.Forms.Tests" -filter:"+[NLog.Windows.Forms]* -[NLog.Windows.Forms.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"NLog.Windows.Forms.Tests" - pip install codecov - codecov -f "coverage.xml" diff --git a/build.ps1 b/build.ps1 index 1b50f77..ef9540e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -2,8 +2,8 @@ # creates NuGet package at \artifacts dotnet --version -$versionPrefix = "4.4.0" # Also update version for minor versions in appveyor.yml -$versionSuffix = "" +$versionPrefix = "4.5.0" # Also update version for minor versions in appveyor.yml +$versionSuffix = "rc.1" $versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER} if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { $versionPrefix = $versionFile