[ 
https://issues.apache.org/jira/browse/LOG4NET-250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16954550#comment-16954550
 ] 

Dominik Psenner commented on LOG4NET-250:
-----------------------------------------

I recall that some work has been done to cache the current windows identity and 
thus significantly improve performance. Maybe this issue is a long open and has 
gone by unnoticed while it should have been marked as a duplicate of the other 
issue. To confirm, it would be sensible to check the commit history and 
identify also the other issue that tracked related work. A very quick lookup 
resulted in the commit hashes 4ee46ec and 8a82ed7, both part of an old pull 
request that did not make it into the develop / master or release branch.

> Drastically decrease amount of time needed for LoggingEvent.UserName
> --------------------------------------------------------------------
>
>                 Key: LOG4NET-250
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-250
>             Project: Log4net
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.2.10
>            Reporter: Hao Zhang
>            Priority: Major
>             Fix For: 1.2/2.0 Maintenance Release
>
>
> Currently, each LoggingEvent retrieves the logged on user using 
> WindowsIdentity.GetCurrent() which takes a long time
> One can obtain drastic improvements by switching to Environment.UserDomain 
> and Environment.UserName
> Here are some numbers on my box running Windows XP SP3, .NET 2.0, debug mode.
> Using Environment:
>             for (int i = 0; i < 50000; i++)
>             {
>                var x = (Environment.UserDomainName + "\\" + 
> Environment.UserName);
>             }
> takes 4294 milliseconds to run (4.294) using Stopwatch
> Using WindowsIdentity:
>             for (int i = 0; i < 50000; i++)
>             {
>                 var x = (WindowsIdentity.GetCurrent().Name);
>             }
>             start.Stop();
> takes 20191 (20 seconds) milliseconds to run,
> Thus, it takes almost 5x longer to use WindowsIdentity.
> This isn't much of an issue if you're not logging extremely high quantities 
> or do not log the user name.
> However, I'm currently using XmlLayoutSchemaLog4j which forces the retrieval 
> of said information for the log4net:UserName property.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to