Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i having problem of exe getting crace crash at after running few days, means two or three days,
that why i want to add some loge code by which i come to know when it is getting crace crash and what happened, why it is getting crace crash. please help me
Posted
Updated 3-Jan-12 7:44am
v3
Comments
Mehdi Gholam 26-Dec-11 1:02am    
EDIT -> corrected spelling
Sergey Alexandrovich Kryukov 26-Dec-11 1:32am    
What is your platform?
--SA
BrainlessLabs.com 26-Dec-11 1:37am    
Well you need to provide more info.

Some simple and platform-independent (you did not share what platform you are using anyway) methods are shown in a code samples here: http://www.daniweb.com/software-development/cpp/threads/121633[^].

—SA
 
Share this answer
 
v2
Comments
Albert Holguin 4-Jan-12 16:04pm    
That solution works... +5
Sergey Alexandrovich Kryukov 4-Jan-12 18:52pm    
Thank you for reassuring, Albert.
--SA
While writing to a log file might help you finding the problem, that isn't the best way. For one you would always have to make sure the file is flushed and closed properly after each log statement, to make sure half of the log statements aren't lost in the cache. Also these files can easily get quite large if you're not careful, and may cause entirely different problems of their own.

The best way to locate an error is using a debugger. Development environments such as Visual Studio or Eclipse offer built-in debuggers that are easy to use and will often put you right at the point in your source code where the crash happens. Make sure to read the online help and documentation for the IDE you have, or if you don't have a debugger yet, do yourself a favor and get one.
 
Share this answer
 
Comments
CPallini 3-Jan-12 13:43pm    
Can he sleep a bit while waiting for the error showing up on the debugger window?
:-)
Stefan_Lang 4-Jan-12 4:21am    
If you refer to the amount of time for the crash to happen, using log info isn't going to take any less time - if anything it will likely be more, because you may not know what info to log right from the start and therefore mayy need to rerun the program several times, whereas in a debug session you can normally investigate the content of all relevant variables immediately.

Of course, in this case you can make an educated guess: An error happening after 2-3 days may likely be related to (a) a timer overflow, (b) a counter overflow, (c) memory leaks. With both a log file or a debugger you might be able to catch case (a) or (b). Case (c) might be detectable (not the leaks itself, but the fact that you've run out of memory) with a debugger, but you will lose that information when using a log file.
Hi,

Writing a log file, need to have understanding of the following API's.

CreateFile()
WriteFile()
GetSystemTime()

write a log file of your own.


Cheers
 
Share this answer
 
Comments
Chuck O'Toole 4-Jan-12 3:44am    
Don't forget SetFilePointer()

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