log rotate and better exception handling