I want to save the log output of the console when flask is running in the development environment to a file.
refers to the Internet, basically first configure logger and then add logger.info ("xxx")
to the code to log.
what I want to achieve is that some of the requests output from the console and the logs printed by default are written directly to the log file.
the logger code I configured is as follows:
-sharpapp.__init__.py
def create_app(config_name):
...
filehandler = logging.handlers.TimedRotatingFileHandler("flask.log", "M", 1, 0)
filehandler.setLevel("DEBUG")
app.logger.addHandler(filehandler
...
the logical effect should be to have a flask.log file generated, and then save another one every minute. The actual effect is that flask.log files are generated, but some requests and other information printed by the console are not available, and new logs are not automatically generated in time.
ask the great god to solve the doubt