Skip to content

Commit 03f686c

Browse files
committed
Revert ":zap: cache resolved windows username when available"
This reverts commit 025d7f6.
1 parent 025d7f6 commit 03f686c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/log4net/Core/LoggingEvent.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,6 @@ public string ThreadName
922922
public string UserName =>
923923
m_data.UserName ??= TryGetCurrentUserName() ?? SystemInfo.NotAvailableText;
924924

925-
private static string _cachedWindowsIdentityName;
926-
927925
private static string TryGetCurrentUserName()
928926
{
929927
#if (NETCF || SSCLI || NETSTANDARD1_3)
@@ -939,13 +937,10 @@ private static string TryGetCurrentUserName()
939937

940938
try
941939
{
942-
if (_cachedWindowsIdentityName is not null)
940+
using (WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent())
943941
{
944-
return _cachedWindowsIdentityName;
942+
return windowsIdentity?.Name ?? "";
945943
}
946-
947-
using var windowsIdentity = WindowsIdentity.GetCurrent();
948-
return _cachedWindowsIdentityName = windowsIdentity?.Name ?? "";
949944
}
950945
catch (PlatformNotSupportedException)
951946
{

0 commit comments

Comments
 (0)