Thursday, March 5, 2009

Logging

Logging is quite useful for debugging. Today I found a nice article on logging [1]. Besides describing what to log at system startup, I also found the concept of ring buffer for logging useful (The method is covered in more detail in [2]). Here, logs are not written into file, but into memory in a ring fashion. At the time the program crashes, the last few logs exist in memory and can be debugged.

In this context, google coredumper [3] might also be useful. The core file contains the complete state of the program at a point of time. A strategy can be that after an assertion fails and before crashing the program, the program dumps core using coredumper. This can help to find the bug that caused the assertion failure.

[1] About Log Files: Parts 1 and 2. http://www.ddj.com/cpp/212902973 and http://www.ddj.com/cpp/214502427
[2] Logging in multi-threaded applications efficiently with ring buffer http://www.ibm.com/developerworks/aix/library/au-buffer/index.html
[3] http://stackoverflow.com/questions/318647/what-is-a-good-way-to-dump-a-linux-core-file-from-inside-a-process

No comments:

Post a Comment