Custom Logging
You may wish to write your own custom logging for use in addition to, or instead of, the standard event handlers. The actual writing of the data to a log is done in the same way as discussed above for the standard events: with a SQL statement that writes out the particulars. However, rather than use the Event Logging element and standard events, you can have the SQL statement execute as part of the regular application flow.
Keep in mind that because you're not using standard events, there will be no automatically-generated Request parameters. It's up to you to see that you have all the right data, Request and Session tokens, etc. that you need for your log at the time when the entry will be written. The @Function.DateTime~ token, for example, is very useful in this situation.
Let's look at two example scenarios. First, imagine that your Logi application uses a Process task to add a new member record and send a confirming email, and you want a record of when that message was sent:
To do this, you can simply add a Procedure.SQL element after your Procedure.Send Mail element, as shown above. The SQL statement writes to the log table and can make use of some of the tokens used to personalize the email message. You can even go so far as to add two Procedure.SQL elements, one under an If Error element that writes to the log if there's a problem sending the message, and one that writes to it if the message was successfully sent. In our second scenario, imagine a report definition that acts as a "wizard", collecting input element selections, and then calls another report definition that displays some kind of results based on the parameters passed to it. You'd like to keep track of usage of the wizard in a log.
To make this log entry, simply add a Local Data element with a child DataLayer.SQL element, as shown above, in the "results" definition. When it loads, the datalayer will run and the log entry will be inserted. You can also use the Local Data element's Condition attribute to control this action dynamically.