remove custom logger, use standard logging library#270
Open
remove custom logger, use standard logging library#270
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request migrates the Microsoft Teams SDK from a custom ConsoleLogger implementation to Python's standard logging library. This is a significant refactoring that aligns the SDK with industry standards and improves integration with other Python libraries and frameworks.
Changes:
- Replaced custom ConsoleLogger with module-level loggers using
logging.getLogger(__name__)throughout all packages - Removed logger from constructors and dependency injection across all plugins and components
- Added NullHandler to all package
__init__.pyfiles following Python logging best practices - Added deprecation warnings for ConsoleLogger and LoggerDependencyOptions
- Regenerated activity handlers to remove logger property requirements
- Updated README documentation with comprehensive logging setup examples
- Refactored tests to use pytest's caplog fixture instead of mock loggers
Reviewed changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/openai/src/microsoft_teams/openai/*.py | Migrated to module-level loggers, removed logger from OpenAIBaseModel |
| packages/mcpplugin/src/microsoft_teams/mcpplugin/*.py | Removed logger from constructors, use module-level loggers |
| packages/devtools/src/microsoft_teams/devtools/devtools_plugin.py | Removed logger dependency injection, use module-level logger |
| packages/common/src/microsoft_teams/common/logging/*.py | Added deprecation warnings to ConsoleLogger |
| packages/common/src/microsoft_teams/common/events/event_emitter.py | Removed EventEmitterOptions, use module-level logger |
| packages/common/src/microsoft_teams/common/http/client.py | Removed logger from ClientOptions, use module-level logger |
| packages/apps/src/microsoft_teams/apps/*.py | Removed logger from App, HttpPlugin, ActivityProcessor, and other core components |
| packages/apps/src/microsoft_teams/apps/routing/*.py | Updated ActivityContext and handlers to use module-level logger |
| packages/apps/src/microsoft_teams/apps/auth/*.py | Removed logger from TokenValidator and middleware |
| packages/botbuilder/src/microsoft_teams/botbuilder/*.py | Removed logger dependency injection |
| packages/a2aprotocol/src/microsoft_teams/a2a/*.py | Migrated to module-level loggers |
| packages/*/init.py | Added NullHandler to all package init files |
| packages/common/README.md | Added comprehensive logging documentation |
| packages/apps/tests/*.py | Refactored tests to use caplog instead of mock loggers |
| packages/common/tests/test_backward_compat.py | Updated backward compatibility tests |
| packages/apps/tests/conftest.py | Added logging configuration fixture |
| packages/apps/scripts/generate_handlers.py | Updated handler generation to remove logger references |
…rosoft/teams.py into lilyydu/remove-custom-logger
corinagum
reviewed
Feb 18, 2026
| logger: Optional[Logger] | ||
| """ | ||
| DEPRECATED: | ||
| This method of setting the logger is deprecated and will be removed in version 2.0.0 GA." |
Contributor
There was a problem hiding this comment.
Suggested change
| This method of setting the logger is deprecated and will be removed in version 2.0.0 GA." | |
| This method of setting the logger is deprecated and will be removed in version 2.0.0 GA. |
Just removing stray quotation
corinagum
reviewed
Feb 18, 2026
Contributor
corinagum
left a comment
There was a problem hiding this comment.
two questions
- does
app_oauth.pyneed to be migrated tologging.getLogger? - do we plan to update the examples as well?
Collaborator
Author
good point! it's referencing the context logger so it technically works, but we should add it to the top level instead so developers can filter at a finer level
I already updated the examples! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE
Previously, we had a custom logger available for customers. However, this didn't integrate very well with the general industry - other libraries and frameworks use python's
logginglibrary (e.g., fastapi, boto3, etc), and most developers are familiar with it. In addition, using the standard library is better for reliability, and requires less maintenance.ConsoleLogger, but added a deprecation warningLoggerDependencyOption, but added a deprecation warning- kept the
EventEmitterOptions(though it only has a logger property)- kept the
ConsoleFormatterandConsoleFilteras an option for developers to use- added the NullHandler so that no logs will show up, unless configured by the developer (added to every package init file)
to do:
example w/ standard logger:
