I'm not sure if it works, but try setting LOGFILE only in the init and exit run, and reset it inbetween.