Please do keep in mind that this is a blocking call, so if you call it from a session-processing callback like OnBeforeRequest or OnBeforeResponse, that session will be blocked until the executable exits. If you call it from a UI-processing callback (e.g. a ToolsAction handler or the like) it will block the UI until the executable exits.
Depending on your needs, you may want to keep a log "in memory" and only flush it to disk from time to time. Or you could write an Exporter that would show up inside File > Export Sessions.