Accessing logger in shiny python

The documentation mentions using print() to write diagnostics, but this only works for my code (i.e. in app.py). I'd like to configure standard python logging so that I can set the log level, and include messages from libraries etc.

for example

logger = logging.getLogger()
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)

    def refresh():
        """`
        When refresh button is click, invoke async task
        """
        logger.info("refresh")

Doesn't log anything to the console but print("refresh") does. I listed all attached loggers, and tried to explicitly use "uvicorn" rather than the root logger but that's not working.

How do I configure logging with shiny?

Figured it out myself

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.