Fix logging issues when used from Flask application.