i have a windows service that get user details and save the result into log text file. and, my problem is when i log off my system and login again ie without restarting the
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.onsessionchange.aspx
This may be your best bet, as Vista and Win7 handle the user sessions much like a terminal server would. This should let you handle session changes and it gives a structure with the relevant information, if you want session ID or reason for session change (logon / logoff / lock etc)