Logging
This article explains how to control the level of log messages generated by Flet library and its underlying components. You may need to enable detailed logging to troubleshoot Flet or when submitting a new Flet issue.
Python#
Flet Python uses the following named loggers:
flet- general framework and transport logging.flet_object_patch- detailed control tree diff/patch logging.flet_components- declarative component lifecycle logging.
For normal use, configure logging before calling ft.run():
This gives you the usual flet logs without too much noise.
To see more detail from the main flet logger, either raise the root logging level:
or set the flet logger explicitly:
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger("flet").setLevel(logging.DEBUG)
flet_object_patch and flet_components set their own level to INFO, so
they do not inherit the root DEBUG level unless you enable them explicitly.
To enable the most verbose diagnostics, set the corresponding loggers to DEBUG:
import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger("flet_object_patch").setLevel(logging.DEBUG)
logging.getLogger("flet_components").setLevel(logging.DEBUG)
Use this level mostly for troubleshooting and issue reports.
Built-in Web Server#
When running a web app, Flet starts its built-in web transport on top of FastAPI and Uvicorn.
The effective level of the flet Python logger is passed to the built-in web
server, so configure flet logging before starting the app:
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger("flet").setLevel(logging.DEBUG)
If you host a Flet ASGI app with your own server process, such as uvicorn or
gunicorn, configure that server's logging separately using its own options.