Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
i develop a windows service, this service should write log in a text file (per 5 minutes), but it isn't wrote when the system go to sleep mode.
why doesn't 'WriteLine()' function write in sleep mode?
what do i do? i need logs in all of times in several days ... please help me.
Posted

See, for instance, this Stack Overflow question: "Windows Service OnPowerEvent"[^].
 
Share this answer
 
Considering the hard drive isn't powered up and spinning while the system is in Sleep mode, this is no surprise.
 
Share this answer
 
Comments
Adam Zgagacz 17-Sep-14 11:50am    
Additionally, if computer is sleeping, there is not much to write abut into log. Your service is sleeping as well and nothing is really happening.
Go to Task Manager and looking under 'the Conditions' tab, you will find a "Wake the computer to run this task" check box.

This could resolve your issue.
 
Share this answer
 
try to do the following
instead of writeline the text , create a property and on the set append text to the file

C#
File.AppendText(filepath, text);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900