We actually log the DML to a table not a file. We have a Log Schema that has the same table structure as the production schema accept each table has Update_Time, Update_User, and Update_Type (I = Insert, D = Delete, U=Update) This allows us to keep track of each modification, and query it when necessary. It is done in a Logging trigger. Below is the code to determine the type of DML.
IF INSERTING THEN
lv_logtype := 'I';
ELSIF UPDATING THEN
lv_logtype := 'U';
lv_logtype := 'D';
For inserts and updates we use the :NEW keyword to write the new data to the log table. For deletes we use the :OLD values.
I'm sure you can tweak this mentality to write records to a file instead of a table. And you can build the actual DML statment if that is necessary.