Redirect Logging to File / Directory


#1

When running a dash app, all the HTTP responses and errors are shown in the CLI by default. Is there a way in Dash to send this logging to a file or a file in a folder instead for debugging at a later time? Or any other ways to do this?

Thanks.


#2

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!


Flask 1.0 Release - Impact On Your Dash Apps
#3

@tbone did chris’s solution work?
My file comes out empty.
Could you please share what you did
Cheers!