Tech Tip: Tips for using Debug Log recording
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: July 16, 2010
The Debug Log can track all the code that is running in your database and actions which occur such as opening or closing forms. The following Tech Tips include more information on this:
- The Debug Log setting must be explicitly set while the database is running
- Debug Log difference: Client vs. Server
- Debug Log location and Client Server
One important thing to keep in mind from all that information is that the debug log can grow very large. As stated in the SET DATABASE PARAMETER documentation:
"Note: This option is provided solely for the purpose of debugging and must not be put into production since it may lead to deterioration of the application performance and saturation of the hard disk."
Although this is true, debug log recording can be extremely useful when trying to isolate the cause of a problem which only occurs in deployment. Using the following strategy the size of the debug log can be managed and the most recent actions at the time of the target behavior can still be recorded.
In the database's On startup method, (or you can run this On server startup, see the Tech Tips referenced above for more information) call:
C_LONGINT(proc) proc:=New process("manage_log_scheduler";64*1024;"log_recording_process") |
And create a method named manage_log_scheduler which is started in the new process:
//start debug log SET DATABASE PARAMETER(Debug Log Recording;2) //delay process for 5 minutes DELAY PROCESS(Current process;60*60*5) //run loop, delete existing log and then delay process for 5 minutes While(True) //turn off debug log recording so all log files are closed SET DATABASE PARAMETER(Debug Log Recording;0) //delete 4DDebugLog documents ARRAY TEXT(docsArray;0) DOCUMENT LIST(Get 4D folder(Logs Folder);docsArray) C_LONGINT($i) For ($i;1;Size of array(docsArray)) If (docsArray{$i}="4DDebugLog_@") DELETE DOCUMENT(Get 4D folder(Logs Folder)+docsArray{$i}) End if End for //turn on debug log recording again SET DATABASE PARAMETER(Debug Log Recording;2) //delay process for 5 minutes again DELAY PROCESS(Current process;60*60*5) End while |
This method will start a process that occassionally wakes up and deletes existing log files. This way the log file should never grow too large. Note that when the target behavior occurs it is important that you capture the debug log at that time. If the manage_log_recording method runs again it could delete the information that you are trying to obtain.