diff --git a/src/NLog.Targets.ElasticSearch.Tests/IntegrationTests.cs b/src/NLog.Targets.ElasticSearch.Tests/IntegrationTests.cs index 17b7a2c..84699d2 100644 --- a/src/NLog.Targets.ElasticSearch.Tests/IntegrationTests.cs +++ b/src/NLog.Targets.ElasticSearch.Tests/IntegrationTests.cs @@ -48,6 +48,7 @@ public void ExceptionSerializationTest(bool hasExceptionFieldLayout) var config = new LoggingConfiguration(); config.LoggingRules.Add(rule); + LogManager.ThrowExceptions = true; LogManager.Configuration = config; var logger = LogManager.GetLogger("Example"); @@ -69,6 +70,7 @@ public void SimpleLogTest() var config = new LoggingConfiguration(); config.LoggingRules.Add(rule); + LogManager.ThrowExceptions = true; LogManager.Configuration = config; var logger = LogManager.GetLogger("Example"); @@ -89,6 +91,7 @@ public void ExceptionTest() var config = new LoggingConfiguration(); config.LoggingRules.Add(rule); + LogManager.ThrowExceptions = true; LogManager.Configuration = config; var logger = LogManager.GetLogger("Example"); @@ -103,6 +106,7 @@ public void ExceptionTest() [Fact(Skip = "Integration")] public void ReadFromConfigTest() { + LogManager.ThrowExceptions = true; LogManager.Configuration = new XmlLoggingConfiguration("NLog.Targets.ElasticSearch.Tests.dll.config"); var logger = LogManager.GetLogger("Example"); diff --git a/src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs b/src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs index e7aa877..dd4dbf8 100644 --- a/src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs +++ b/src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs @@ -1,17 +1,20 @@ -using Elasticsearch.Net; +using System; +using System.Collections.Generic; +using System.Dynamic; +using System.Linq; +using System.Threading; +using Elasticsearch.Net; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using NLog.Common; using NLog.Config; using NLog.Layouts; -using System; -using System.Collections.Generic; -using System.Dynamic; -using System.Linq; -using System.Threading; namespace NLog.Targets.ElasticSearch { + /// + /// NLog Target for writing to ElasticSearch using low level client + /// [Target("ElasticSearch")] public class ElasticSearchTarget : TargetWithLayout, IElasticSearchTarget { @@ -143,12 +146,16 @@ public string CloudId [Obsolete("No longer needed", true)] public bool ThrowExceptions { get; set; } + /// + /// Initializes a new instance of the class. + /// public ElasticSearchTarget() { Name = "ElasticSearch"; OptimizeBufferReuse = true; } + /// protected override void InitializeTarget() { base.InitializeTarget(); @@ -201,11 +208,13 @@ protected override void InitializeTarget() _excludedProperties = new HashSet(ExcludedProperties.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } + /// protected override void Write(AsyncLogEventInfo logEvent) { SendBatch(new[] { logEvent }); } + /// protected override void Write(IList logEvents) { SendBatch(logEvents); diff --git a/src/NLog.Targets.ElasticSearch/ExpandoObjectExtensions.cs b/src/NLog.Targets.ElasticSearch/ExpandoObjectExtensions.cs index 97d9078..8c85a19 100644 --- a/src/NLog.Targets.ElasticSearch/ExpandoObjectExtensions.cs +++ b/src/NLog.Targets.ElasticSearch/ExpandoObjectExtensions.cs @@ -4,7 +4,7 @@ namespace NLog.Targets.ElasticSearch { - public static class ExpandoObjectExtensions + internal static class ExpandoObjectExtensions { /// /// Replaces dot ('.') character in Keys with an underscore ('_') diff --git a/src/NLog.Targets.ElasticSearch/Field.cs b/src/NLog.Targets.ElasticSearch/Field.cs index 94583d0..323083f 100644 --- a/src/NLog.Targets.ElasticSearch/Field.cs +++ b/src/NLog.Targets.ElasticSearch/Field.cs @@ -4,17 +4,33 @@ namespace NLog.Targets.ElasticSearch { + /// + /// Additional field details + /// [NLogConfigurationItem] public class Field { + /// + /// Name of additional field + /// [RequiredParameter] public string Name { get; set; } + /// + /// Value with NLog rendering support + /// [RequiredParameter] public Layout Layout { get; set; } + /// + /// Custom type conversion from default string to other type + /// + /// + /// can be used if the renders JSON + /// public Type LayoutType { get; set; } = typeof(string); + /// public override string ToString() { return $"Name: {Name}, LayoutType: {LayoutType}, Layout: {Layout}"; diff --git a/src/NLog.Targets.ElasticSearch/IElasticSearchTarget.cs b/src/NLog.Targets.ElasticSearch/IElasticSearchTarget.cs index 8376389..0b9b37b 100644 --- a/src/NLog.Targets.ElasticSearch/IElasticSearchTarget.cs +++ b/src/NLog.Targets.ElasticSearch/IElasticSearchTarget.cs @@ -4,6 +4,9 @@ namespace NLog.Targets.ElasticSearch { + /// + /// Interface for NLog Target for writing to ElasticSearch + /// public interface IElasticSearchTarget { /// diff --git a/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj b/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj index 9f2fb9c..5948d25 100644 --- a/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj +++ b/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj @@ -12,12 +12,14 @@ true false NLog.Targets.ElasticSearch.snk + true - - - + + + +