Write to the correct log file