diff --git a/src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs b/src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs
index 0346d38..89ed1d8 100644
--- a/src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs
+++ b/src/NLog.Targets.ElasticSearch/ElasticSearchTarget.cs
@@ -27,9 +27,10 @@ public class ElasticSearchTarget : TargetWithLayout, IElasticSearchTarget
///
/// Gets or sets a connection string name to retrieve the Uri from.
- ///
+ ///
/// Use as an alternative to Uri
///
+ [Obsolete("Deprecated. Please use the configsetting layout renderer instead.", true)]
public string ConnectionStringName { get; set; }
///
@@ -106,10 +107,10 @@ public class ElasticSearchTarget : TargetWithLayout, IElasticSearchTarget
///
/// Gets or sets if exceptions will be rethrown.
- ///
+ ///
/// Set it to true if ElasticSearchTarget target is used within FallbackGroup target (https://github.com/NLog/NLog/wiki/FallbackGroup-target).
///
- [Obsolete("No longer needed")]
+ [Obsolete("No longer needed", true)]
public bool ThrowExceptions { get; set; }
public ElasticSearchTarget()
@@ -122,7 +123,7 @@ protected override void InitializeTarget()
{
base.InitializeTarget();
- var uri = ConnectionStringName.GetConnectionString() ?? (_uri?.Render(LogEventInfo.CreateNullEvent())) ?? string.Empty;
+ var uri = _uri?.Render(LogEventInfo.CreateNullEvent()) ?? string.Empty;
var nodes = uri.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(url => new Uri(url));
var connectionPool = new StaticConnectionPool(nodes);
diff --git a/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj b/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj
index 03921e0..a35ecdc 100644
--- a/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj
+++ b/src/NLog.Targets.ElasticSearch/NLog.Targets.ElasticSearch.csproj
@@ -18,7 +18,6 @@
-
diff --git a/src/NLog.Targets.ElasticSearch/StringExtensions.cs b/src/NLog.Targets.ElasticSearch/StringExtensions.cs
index eb8bf77..71cae74 100644
--- a/src/NLog.Targets.ElasticSearch/StringExtensions.cs
+++ b/src/NLog.Targets.ElasticSearch/StringExtensions.cs
@@ -2,7 +2,6 @@
using System.Dynamic;
using System.Globalization;
using Newtonsoft.Json;
-using Microsoft.Extensions.Configuration;
using System.IO;
namespace NLog.Targets.ElasticSearch
@@ -35,23 +34,5 @@ public static object ToSystemType(this string field, Type type, IFormatProvider
return field;
}
}
-
- public static string GetConnectionString(this string name)
- {
- if (string.IsNullOrEmpty(name))
- return null;
-
- var value = Environment.GetEnvironmentVariable(name);
- if (!string.IsNullOrEmpty(value))
- return value;
-
- var builder = new ConfigurationBuilder()
- .SetBasePath(Directory.GetCurrentDirectory())
- .AddJsonFile("appsettings.json", true, reloadOnChange: false); // CreateFileWatcher not supported on all platforms, and not needed
-
- var configuration = builder.Build();
-
- return configuration.GetConnectionString(name);
- }
}
}
\ No newline at end of file