Skip to content
This repository was archived by the owner on Jan 17, 2026. It is now read-only.

Commit 8f57b85

Browse files
snakefootmarkmcdowell
authored andcommitted
Updated Elasticsearch.Net ver. 7.4.2 to fix performance issue
1 parent 51483d9 commit 8f57b85

6 files changed

Lines changed: 44 additions & 10 deletions

File tree

src/NLog.Targets.ElasticSearch.Tests/IntegrationTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public void ExceptionSerializationTest(bool hasExceptionFieldLayout)
4848
var config = new LoggingConfiguration();
4949
config.LoggingRules.Add(rule);
5050

51+
LogManager.ThrowExceptions = true;
5152
LogManager.Configuration = config;
5253

5354
var logger = LogManager.GetLogger("Example");
@@ -69,6 +70,7 @@ public void SimpleLogTest()
6970
var config = new LoggingConfiguration();
7071
config.LoggingRules.Add(rule);
7172

73+
LogManager.ThrowExceptions = true;
7274
LogManager.Configuration = config;
7375

7476
var logger = LogManager.GetLogger("Example");
@@ -89,6 +91,7 @@ public void ExceptionTest()
8991
var config = new LoggingConfiguration();
9092
config.LoggingRules.Add(rule);
9193

94+
LogManager.ThrowExceptions = true;
9295
LogManager.Configuration = config;
9396

9497
var logger = LogManager.GetLogger("Example");
@@ -103,6 +106,7 @@ public void ExceptionTest()
103106
[Fact(Skip = "Integration")]
104107
public void ReadFromConfigTest()
105108
{
109+
LogManager.ThrowExceptions = true;
106110
LogManager.Configuration = new XmlLoggingConfiguration("NLog.Targets.ElasticSearch.Tests.dll.config");
107111

108112
var logger = LogManager.GetLogger("Example");

src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
using Elasticsearch.Net;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Dynamic;
4+
using System.Linq;
5+
using System.Threading;
6+
using Elasticsearch.Net;
27
using Newtonsoft.Json;
38
using Newtonsoft.Json.Converters;
49
using NLog.Common;
510
using NLog.Config;
611
using NLog.Layouts;
7-
using System;
8-
using System.Collections.Generic;
9-
using System.Dynamic;
10-
using System.Linq;
11-
using System.Threading;
1212

1313
namespace NLog.Targets.ElasticSearch
1414
{
15+
/// <summary>
16+
/// NLog Target for writing to ElasticSearch using low level client
17+
/// </summary>
1518
[Target("ElasticSearch")]
1619
public class ElasticSearchTarget : TargetWithLayout, IElasticSearchTarget
1720
{
@@ -143,12 +146,16 @@ public string CloudId
143146
[Obsolete("No longer needed", true)]
144147
public bool ThrowExceptions { get; set; }
145148

149+
/// <summary>
150+
/// Initializes a new instance of the <see cref="ElasticSearchTarget"/> class.
151+
/// </summary>
146152
public ElasticSearchTarget()
147153
{
148154
Name = "ElasticSearch";
149155
OptimizeBufferReuse = true;
150156
}
151157

158+
/// <inheritdoc />
152159
protected override void InitializeTarget()
153160
{
154161
base.InitializeTarget();
@@ -201,11 +208,13 @@ protected override void InitializeTarget()
201208
_excludedProperties = new HashSet<string>(ExcludedProperties.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
202209
}
203210

211+
/// <inheritdoc />
204212
protected override void Write(AsyncLogEventInfo logEvent)
205213
{
206214
SendBatch(new[] { logEvent });
207215
}
208216

217+
/// <inheritdoc />
209218
protected override void Write(IList<AsyncLogEventInfo> logEvents)
210219
{
211220
SendBatch(logEvents);

src/NLog.Targets.ElasticSearch/ExpandoObjectExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace NLog.Targets.ElasticSearch
66
{
7-
public static class ExpandoObjectExtensions
7+
internal static class ExpandoObjectExtensions
88
{
99
/// <summary>
1010
/// Replaces dot ('.') character in Keys with an underscore ('_')

src/NLog.Targets.ElasticSearch/Field.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,33 @@
44

55
namespace NLog.Targets.ElasticSearch
66
{
7+
/// <summary>
8+
/// Additional field details
9+
/// </summary>
710
[NLogConfigurationItem]
811
public class Field
912
{
13+
/// <summary>
14+
/// Name of additional field
15+
/// </summary>
1016
[RequiredParameter]
1117
public string Name { get; set; }
1218

19+
/// <summary>
20+
/// Value with NLog <see cref="NLog.Layouts.Layout"/> rendering support
21+
/// </summary>
1322
[RequiredParameter]
1423
public Layout Layout { get; set; }
1524

25+
/// <summary>
26+
/// Custom type conversion from default string to other type
27+
/// </summary>
28+
/// <remarks>
29+
/// <see cref="System.Object"/> can be used if the <see cref="Layout"/> renders JSON
30+
/// </remarks>
1631
public Type LayoutType { get; set; } = typeof(string);
1732

33+
/// <inheritdoc />
1834
public override string ToString()
1935
{
2036
return $"Name: {Name}, LayoutType: {LayoutType}, Layout: {Layout}";

src/NLog.Targets.ElasticSearch/IElasticSearchTarget.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace NLog.Targets.ElasticSearch
66
{
7+
/// <summary>
8+
/// Interface for NLog Target for writing to ElasticSearch
9+
/// </summary>
710
public interface IElasticSearchTarget
811
{
912
/// <summary>

src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
<SignAssembly>true</SignAssembly>
1313
<DelaySign>false</DelaySign>
1414
<AssemblyOriginatorKeyFile>NLog.Targets.ElasticSearch.snk</AssemblyOriginatorKeyFile>
15+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1516
</PropertyGroup>
1617

1718
<ItemGroup>
18-
<PackageReference Include="Elasticsearch.Net" Version="7.2.1" />
19-
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
20-
<PackageReference Include="NLog" Version="4.6.6" />
19+
<PackageReference Include="Elasticsearch.Net" Version="7.4.2" />
20+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
21+
<PackageReference Include="NLog" Version="4.6.8" />
22+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
2123
</ItemGroup>
2224

2325
</Project>

0 commit comments

Comments
 (0)