Debugging or tracing compiled code is sometimes difficult. Your application may crash only in compiled mode, or your process is very slow and profiling the code is required. The only way to handle this is to define some static check points in your methods and keep a record of this information when the code is executing.
To do so, you can create a log file and append data to it. This can be a text file to which each process can open and append information. The most common way to achieve that is to open a document and send text using the SEND PACKET command. However, you need to be sure that not all processes open the document at the same time, otherwise you need to open a document per process. Then, the packet to be sent is usually static.
Windows NT, 2000 and XP already have a log file in which 4D can store information. If you want to use it, you just have to send your message using the LOG EVENT command. For that command, you just need to provide a message and its type (information, warning, or error message).
You may choose to combine this command with the Current method name command. Current method name returns the name of the method currently executed. This information can prove very useful if inserted in the log. Other useful commands would be the commands Current date, Current time and Current user. The Tickcount command would be recommended for a profiling issue.
Depending on your case, you can log your message as a piece of information (profiling, debugging), as a warning (something's wrong but it's not a real issue) or as an error (an error occurred).