2016-10-13 67 views
0

为什么我的log4net没有登录后Impersonate,开始登录后Undolog4net未登录后模拟

testDebug 6不是日志。

我该怎么办呢?

 logger.Debug("testDebug 5"); 
     // The token that is passed to the following constructor must 
     // be a primary token in order to use it for impersonation. 
     WindowsIdentity newId = new WindowsIdentity(dupeTokenHandle); 
     WindowsImpersonationContext impersonatedUser = newId.Impersonate(); 
     logger.Debug("testDebug 6"); 
     // Check the identity. 
     // Console.WriteLine("After impersonation: " 
     // + WindowsIdentity.GetCurrent().Name); 
     if (Config.DebugMode().Trim().ToUpper() == "ON") 
      logger.Debug("After impersonation: " + WindowsIdentity.GetCurrent().Name); 

     //////// Put your code here //////// 

     ReceiveEmail(); 

     /////////////////////////////////// 

     // Stop impersonating the user. 
     impersonatedUser.Undo(); 
     logger.Debug("testDebug 7"); 

回答

1

很可能模拟的用户不具有对日志文件的写/附加访问权限。