Skip to content

Commit

Permalink
LoggingConfiguration - Expand NLog Config Variables without issues on…
Browse files Browse the repository at this point in the history
… Net50 (#4273)
  • Loading branch information
snakefoot authored Feb 14, 2021
1 parent 3755739 commit d901724
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/NLog/Config/LoggingConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/NLog/Config/LoggingConfigurationParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/NLog/LayoutRenderers/AppSettingLayoutRenderer2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/NLog/LayoutRenderers/RegistryLayoutRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private static ParseResult ParseKey(string key)
/// <summary>
/// Aliases for the hives. See https://msdn.microsoft.com/en-us/library/ctb3kd86(v=vs.110).aspx
/// </summary>
private static readonly Dictionary<string, RegistryHive> HiveAliases = new Dictionary<string, RegistryHive>(StringComparer.InvariantCultureIgnoreCase)
private static readonly Dictionary<string, RegistryHive> HiveAliases = new Dictionary<string, RegistryHive>(StringComparer.OrdinalIgnoreCase)
{
{"HKEY_LOCAL_MACHINE", RegistryHive.LocalMachine},
{"HKLM", RegistryHive.LocalMachine},
Expand Down
4 changes: 2 additions & 2 deletions src/NLog/Targets/EventLogTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit d901724

Please sign in to comment.