Debugging Gateway Event

I'm trying to debug a gateway event. The event is adding extra entries to a SQL table. I've tried resetting the table (deleting all rows) and the event makes the correct entries on its first run. After that, it makes some erroneous entries. After the first run, I've tried copy and pasting the script into the script console and running that. This does not make the erroneous entries. Can I set up a logger of some sort that can print values that are generated during a gateway event?

logger = system.util.getLogger("MyLoggerName")
logger.info("Some data.")
myVariable = 22 + 20
logger.info("Important value: {0}".format(myVariable))

You really should not use jython's formatter with IA loggers. They will be dramatically slower than the native formatter. Your line of code should be:

logger.infof("Important value: %s", myVariable)

Also, this is way more lightweight when a particular logging level is turned off--the formatter will be skipped.