flask log

import logging
from logging.handlers import RotatingFileHandler from flask import Flask app = Flask(__name__) @app.route('/')
def foo():
app.logger.warning('A warning occurred (%d apples)', 42)
app.logger.error('An error occurred')
app.logger.info('Info')
return "foo" if __name__ == '__main__':
handler = RotatingFileHandler('foo.log', maxBytes=10000, backupCount=1)
handler.setLevel(logging.INFO)
app.logger.addHandler(handler)
app.run()

  

import logging
  from logging.handlers import RotatingFileHandler
   
  from flask import Flask
   
  app = Flask(__name__)
   
  @app.route('/')
  def foo():
  app.logger.warning('A warning occurred (%d apples)', 42)
  app.logger.error('An error occurred')
  app.logger.info('Info')
  return "foo"
   
  if __name__ == '__main__':
  handler = RotatingFileHandler('foo.log', maxBytes=10000, backupCount=1)
  handler.setLevel(logging.INFO)
  app.logger.addHandler(handler)
  app.run()
上一篇:什么?用python能实现自动登录CSDN,1000W个CSDN用户表示也太爽啦


下一篇:The Ph.D. Grind