Namespace: log4net.Core
Assembly: log4net (in log4net.dll) Version: 2.0.6.0-.NET 4.0
Property Value
Type: StringThe name of the current user, or NOT AVAILABLE when the underlying runtime has no support for retrieving the name of the current user.
Calls WindowsIdentity.GetCurrent().Name to get the name of the current windows user.
To improve performance, we could cache the string representation of the name, and reuse that as long as the identity stayed constant. Once the identity changed, we would need to re-assign and re-render the string.
However, the WindowsIdentity.GetCurrent() call seems to return different objects every time, so the current implementation doesn't do this type of caching.
Timing for these operations:
Method | Results |
---|---|
WindowsIdentity.GetCurrent() | 10000 loops, 00:00:00.2031250 seconds |
WindowsIdentity.GetCurrent().Name | 10000 loops, 00:00:08.0468750 seconds |
This means we could speed things up almost 40 times by caching the value of the WindowsIdentity.GetCurrent().Name property, since this takes (8.04-0.20) = 7.84375 seconds.