Administration Guide > TDV Logging Information > Configuring and Enabling Event Logging > Customizing Audit Log File Behavior
 
Customizing Audit Log File Behavior
You can customize the TDV event handler to create an audit log file that captures TDV requests. Depending on your audit file needs, you might want to write a custom event handler and configure your TDV events with different values.
The TDV event handler API is not limited to audit file log events. You can create a custom event handler that captures the specific information that you need.
To customize audit log behavior using a custom event handler
1. Create a customEventHandler.jar event handler that extends com.compositesw.extension.events.EventHandler. The JAR file must be named customEventHandler.jar.
The following sample code captures events and saves them to a log file under /tmp on UNIX:
import com.compositesw.extension.events.EventHandler;
 
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Set;
import java.util.Date;
import java.util.Locale;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
 
public class SampleEventHandler
implements EventHandler
{
 
private DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ",Locale.US);
 
public void handleEvent(Map eventInfo)
throws Exception
{
File f = new File("/tmp/events.log");
PrintWriter log = new PrintWriter(new FileWriter(f, true));
 
log.println("Event:");
 
long time = Long.parseLong((String)eventInfo.get("time"));
String dateString = df.format(new Date(time));
log.println("\tdate-->" + df.format(new Date(time)));
 
Set keys = eventInfo.keySet();
for (Object key : keys) {
log.println("\t" + key.toString() + "-->" + eventInfo.get(key));
}
log.flush();
}
}
 
2. Stop the TDV Server.
3. Copy customEventHandler.jar and save it in the <TDV_install_dir>/apps/extension/lib directory.
4. Start the TDV Server.
5. Open and log in to Studio as an admin user.
6. From the Administration menu, choose Configuration.
7. Navigate to Server > Events and Logging.
8. Make sure that Enable System Events is set to True.
9. Navigate to Server > Events and Logging > Logging > Custom Logger.
10. For Custom Jar Location, type the fully qualified directory of the customEventHandler.jar that you created in Step 1.
11. For Enable Custom Logging, select True.
12. Enable custom audit requests under Server > Events and Logging > Event Generation > Request Events. There are many types of events that you can schedule.
For this example set the value of the following parameters as indicated in the following table:
Configuration Parameter
Value for the Example
Request Start
DB, LOG, CUSTOM
Request End
DB, LOG, CUSTOM
Request Fail
DB, LOG, CUSTOM
13. Optionally, to capture the web services name in the log file, the Enable Events for Internal Request property must be set to true.
14. Restart the TDV Server.
15. To see the TDV request events in the example log file:
a. Log into Studio.
b. In the resource tree, go to Desktop > Data Services > Databases > system > LOG_EVENTS.
c. Open the LOG_EVENTS table.
d. Execute the table query so that events are sent to the log file.
e. Outside of Studio, open the log file and see the TDV event details for the Request Start and Request End events.