Revert ":zap: cache resolved windows username when available"
This reverts commit 025d7f6ac197fc8ca92c776b14d9205d6b899168.
diff --git a/src/log4net/Core/LoggingEvent.cs b/src/log4net/Core/LoggingEvent.cs
index 8d89ff9..26b76ba 100644
--- a/src/log4net/Core/LoggingEvent.cs
+++ b/src/log4net/Core/LoggingEvent.cs
@@ -922,8 +922,6 @@
public string UserName =>
m_data.UserName ??= TryGetCurrentUserName() ?? SystemInfo.NotAvailableText;
- private static string _cachedWindowsIdentityName;
-
private static string TryGetCurrentUserName()
{
#if (NETCF || SSCLI || NETSTANDARD1_3)
@@ -939,13 +937,10 @@
try
{
- if (_cachedWindowsIdentityName is not null)
+ using (WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent())
{
- return _cachedWindowsIdentityName;
+ return windowsIdentity?.Name ?? "";
}
-
- using var windowsIdentity = WindowsIdentity.GetCurrent();
- return _cachedWindowsIdentityName = windowsIdentity?.Name ?? "";
}
catch (PlatformNotSupportedException)
{