Change: STDOUT.sync = true

Because we want to redirect to a log file, and then synchronize the output.