Registering flags - configuring debugging

I am using the following configuration for my Flask application:

class StagingConfig(Config):
    DEBUG = False
    MONGO_DB_NAME = "res_stage_database"

    def init_app(cls, app):
        import logging
        from logging.handlers import RotatingFileHandler
        rotating_handler = RotatingFileHandler(filename='gunicorn.out', maxBytes=10000000, backupCount=5)
        formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
        app.logger.addHandler(rotating_handler)"Using StagingConfig")
        app.logger.error("Using StagingConfig")


(Above, only add the error message at gunicorn.out

- 2015-04-26 18: 03: 38,182 - ERROR - Using StagingConfig)

Since this configuration is used in a staged application, I want DEBUG to be False so that I don't get Flask debug screens on errors, but instead a standard 500 error screen. Although for some reason, when DEBUG is set to False, logging of error messages other than errors stops.

Once the parameter is DEBUG

set to True, registration is correct. Shouldn't these values ​​be independent as I set my log level in the log handler?


source to share

1 answer

It turns out I had to use app.logger.setLevel(logging.INFO)

instead of setting the level on the handler.



All Articles