Logging Tree

1.10 · active · verified Fri Apr 17

The `logging-tree` library provides a simple way to introspect and display the logger hierarchy from Python's built-in `logging` module. It helps developers visualize how loggers are configured, including their levels and handlers. The current version is 1.10, with releases occurring periodically to add minor features or address issues.

Common errors

Warnings

Install

Imports

Quickstart

This example configures a basic logging hierarchy and then uses `logging_tree.printout()` to display the structure of all active loggers, their levels, and handlers.

import logging
from logging_tree import printout

# Configure some loggers to demonstrate the tree
root_logger = logging.getLogger()
root_logger.setLevel(logging.INFO)
root_logger.addHandler(logging.StreamHandler())

app_logger = logging.getLogger('my_app')
app_logger.setLevel(logging.DEBUG)

module_logger = logging.getLogger('my_app.sub_module')
module_logger.setLevel(logging.WARNING)

# Log some messages to ensure loggers are active
root_logger.info('Root logger message')
app_logger.debug('App logger message')
module_logger.warning('Sub-module logger message')

# Display the logging tree
print('\nLogging Tree:')
printout()

view raw JSON →