🗃️ Custom Logger
The App will provide a default logger, but you can also provide your own.
The default Logger instance will be set to Python's standard logging module, using logging.getLogger(__name__) per module. from the microsoft-teams-common package.
The Python SDK uses standard logging — there's no custom logger to inject into App. To see SDK log output, attach a handler to the microsoft_teams logger hierarchy. The SDK ships a ConsoleFormatter with color-coded output if you want it:
import logging
import os
from microsoft_teams.common import ConsoleFormatter
handler = logging.StreamHandler()
handler.setFormatter(ConsoleFormatter())
logging.getLogger("microsoft_teams").addHandler(handler)
logging.getLogger("microsoft_teams").setLevel(
os.getenv("LOG_LEVEL", "INFO").upper()
)
Log Levels
Python's standard logging levels apply: DEBUG, INFO, WARNING, ERROR, CRITICAL.
Filtering by Logger Name
Each logger is created with a name. You can filter which loggers emit output by providing a name pattern, using * as a wildcard.
Use ConsoleFilter to limit which loggers emit, matched by name with * wildcards:
from microsoft_teams.common import ConsoleFilter, ConsoleFormatter
handler = logging.StreamHandler()
handler.setFormatter(ConsoleFormatter())
handler.addFilter(ConsoleFilter("microsoft_teams*")) # only SDK loggers
logging.getLogger().addHandler(handler)
Environment Variables
The Python SDK does not read logging environment variables on its own. If you want LOG_LEVEL to control verbosity, read it yourself at startup:
import os
logging.getLogger().setLevel(os.getenv("LOG_LEVEL", "INFO").upper())