make sure log is resource before closing