I have a Flask application, which uses Tornado as the web server. On the live server, something is going wrong and I get the error message "500 Internal Server Error".
I want to know what is going wrong, and I'd like the text of all uncaught exceptions to go to the log file. How do I do this?
My code to start up Tornado looks like this:
def doLogging():
""" make Tornado do logging """
import tornado.options
import tornado.log
logger = logging.getLogger("ewa")
pathToHere = os.path.dirname(os.path.realpath(__file__))
logPan = butil.join(pathToHere, "../logs/ewa.log")
fh = logging.FileHandler(logPan)
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s:%(name)s:"
"%(levelname)s:%(message)s")
fh.setFormatter(formatter)
logger.addHandler(fh)
tornado.log.enable_pretty_logging(None, logger)
logger.info("===== web server started =====")
logger.warn("(a warning message)")
logger.error("(an error message)")
logger.critical("(a critical message)")
if __name__ == "__main__":
doLogging()
container = wsgi.WSGIContainer(main.app)
http_server = httpserver.HTTPServer(container)
http_server.listen(8210)
ioloop.IOLoop.instance().start()
This correctly creates the log file, but uncaught exceptions aren't being logged.
Aucun commentaire:
Enregistrer un commentaire