Redirect Logging to File / Directory

Googling “Flask file logger”, I found this: https://gist.github.com/ibeex/3257877

Adapting this to Dash would look something like:

import logging
from logging.handlers import RotatingFileHandler

import dash

app = dash.Dash()

if __name__ == '__main__':
    handler = RotatingFileHandler('foo.log', maxBytes=10000, backupCount=1)
    handler.setLevel(logging.INFO)
    app.server.logger.addHandler(handler)
    app.run_server()

I haven’t tested this, but I’d recommend searching for something along these lines. Be sure to let us know what you end up with!

2 Likes