Added logging. Reorganized wsgi app generation code.