diff --git a/src/NLog/Config/LoggingConfiguration.cs b/src/NLog/Config/LoggingConfiguration.cs
index 7d8921a447..bcdca2ca98 100644
--- a/src/NLog/Config/LoggingConfiguration.cs
+++ b/src/NLog/Config/LoggingConfiguration.cs
@@ -834,7 +834,7 @@ internal string ExpandSimpleVariables(string input)
{
string output = input;
- if (Variables.Count > 0 && output?.IndexOf("${") >= 0)
+ if (Variables.Count > 0 && output?.IndexOf('$') >= 0)
{
// TODO - make this case-insensitive, will probably require a different approach
var variables = Variables.ToList();
diff --git a/src/NLog/Config/LoggingConfigurationParser.cs b/src/NLog/Config/LoggingConfigurationParser.cs
index 65949f66e4..3a1bc22485 100644
--- a/src/NLog/Config/LoggingConfigurationParser.cs
+++ b/src/NLog/Config/LoggingConfigurationParser.cs
@@ -249,7 +249,7 @@ private string ExpandFilePathVariables(string internalLogFile)
if (ContainsSubStringIgnoreCase(internalLogFile, "${processdir}", out string processDirToken))
internalLogFile = internalLogFile.Replace(processDirToken, System.IO.Path.GetDirectoryName(LogFactory.CurrentAppEnvironment.CurrentProcessFilePath) + System.IO.Path.DirectorySeparatorChar.ToString());
#endif
- if (internalLogFile.IndexOf("%", StringComparison.OrdinalIgnoreCase) >= 0)
+ if (internalLogFile.IndexOf('%') >= 0)
internalLogFile = Environment.ExpandEnvironmentVariables(internalLogFile);
#endif
return internalLogFile;
diff --git a/src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs b/src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs
index f34446dcee..ee6cce4bfe 100644
--- a/src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs
+++ b/src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs
@@ -83,7 +83,7 @@ public sealed class AppSettingLayoutRenderer2 : LayoutRenderer, IStringValueRend
protected override void InitializeLayoutRenderer()
{
string connectionStringSection = "ConnectionStrings.";
- _connectionStringName = Item?.TrimStart().StartsWith(connectionStringSection, StringComparison.InvariantCultureIgnoreCase) == true ?
+ _connectionStringName = Item?.TrimStart().StartsWith(connectionStringSection, StringComparison.OrdinalIgnoreCase) == true ?
Item.TrimStart().Substring(connectionStringSection.Length) : null;
}
diff --git a/src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs b/src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs
index 73db6655b4..7d7256825e 100644
--- a/src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs
+++ b/src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs
@@ -236,7 +236,7 @@ private static ParseResult ParseKey(string key)
///
/// Aliases for the hives. See https://msdn.microsoft.com/en-us/library/ctb3kd86(v=vs.110).aspx
///
- private static readonly Dictionary HiveAliases = new Dictionary(StringComparer.InvariantCultureIgnoreCase)
+ private static readonly Dictionary HiveAliases = new Dictionary(StringComparer.OrdinalIgnoreCase)
{
{"HKEY_LOCAL_MACHINE", RegistryHive.LocalMachine},
{"HKLM", RegistryHive.LocalMachine},
diff --git a/src/NLog/Targets/EventLogTarget.cs b/src/NLog/Targets/EventLogTarget.cs
index 4671c69f12..476735a15b 100644
--- a/src/NLog/Targets/EventLogTarget.cs
+++ b/src/NLog/Targets/EventLogTarget.cs
@@ -341,7 +341,7 @@ private void WriteEntry(string eventLogSource, string message, EventLogEntryType
else
{
var currentLogName = _eventLogWrapper.LogNameFromSourceName(eventLogSource, MachineName);
- if (!currentLogName.Equals(Log, StringComparison.CurrentCultureIgnoreCase))
+ if (!currentLogName.Equals(Log, StringComparison.OrdinalIgnoreCase))
{
InternalLogger.Debug("EventLogTarget(Name={0}): Source {1} should be mapped to Log {2}, but EventLog.LogNameFromSourceName returns {3}", Name, eventLogSource, Log, currentLogName);
}
@@ -424,7 +424,7 @@ private void CreateEventSourceIfNeeded(string fixedSource, bool alwaysThrowError
if (_eventLogWrapper.SourceExists(fixedSource, MachineName))
{
string currentLogName = _eventLogWrapper.LogNameFromSourceName(fixedSource, MachineName);
- if (!currentLogName.Equals(Log, StringComparison.CurrentCultureIgnoreCase))
+ if (!currentLogName.Equals(Log, StringComparison.OrdinalIgnoreCase))
{
InternalLogger.Debug("EventLogTarget(Name={0}): Updating source {1} to use log {2}, instead of {3} (Computer restart is needed)", Name, fixedSource, Log, currentLogName);