Plotly’s Dash has made it very easy to put together small dashboards; there are components for html and even custom react components that have een built onto of python objects. These can make it easy to display pandas dataframes, important metrics, or plots that update based on user interaction.
When you are writing applications where you want to capture some of the logs for users – especially for internal facing cases it can be useful to capture these in the page.

One of the ways that this can be done in Python is using the built-in logging. There are great utilities for capturing streams and saving them to rotating log files or displaying them on the console. Capturing these logs and displaying them to users within the application can help advanced users determine issues when interacting due to file corruption, formatting, etc. without writing complicated UI to capture this information. In dash, decorators are used to wrap functions to allow for functions to react to user inputs and generate outputs that then update the react components.

Python offers the robust logging handlers with three specific: StreamHandler, FileHandler, and NullHandler. These can be used to build out loggers as I will show below. The chocies are to either to redirect the stream to a file, read, and then display to the console or cpature the stream and display the most recent adding to the client state.

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import logging
import sys

logger = logging.getLogger(__name__)

class DashLogger(logging.StreamHandler):
    def __init__(self, stream=None):
        self.logs = list()

    def emit(self, record):
            msg = self.format(record)
            self.logs = self.logs[-1000:]
        except Exception:

dash_logger = DashLogger(stream=sys.stdout)

external_stylesheets = ['']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div([
    html.Button('Submit', id='button'),
        interval=1 * 1000  # in milliseconds

    Output('log', 'children'),
    [Input('log-update', 'n_intervals')])
def update_logs(interval):
    return [html.Div(log) for log in dash_logger.logs]

@app.callback(Output('my-div', 'children'), [Input('button', 'n_clicks')])
def add_log(click):
    logger.warning("Important Message")

if __name__ == '__main__':

The above example dash application will append html divs to the Div with the id of log.