2016-10-13 63 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

很可能模擬的用戶不具有對日誌文件的寫/附加訪問權限。