Skip to content

Conversation

@edgarrmondragon
Copy link
Contributor

@edgarrmondragon edgarrmondragon commented Feb 17, 2025

Rationale

  • Not using the root logger lets the end user better control logging for specific packages and modules, e.g. by configuring langchain_aws.llms to log at the ERROR level, but langchain_aws.llms.bedrock at the DEBUG level.
  • Using logger.exception adds exception info to the log record. This is particularly useful if you want to use a library like python-json-logger or structlog, where the exception info could be nicely formatted into an array/object.

@edgarrmondragon edgarrmondragon marked this pull request as ready for review February 19, 2025 16:47
Copy link
Collaborator

@3coins 3coins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@3coins 3coins merged commit 5d1c282 into langchain-ai:main Feb 20, 2025
12 checks passed
@edgarrmondragon edgarrmondragon deleted the log-exceptions branch February 20, 2025 21:16
murilosimao pushed a commit to murilosimao/langchain-aws that referenced this pull request Oct 29, 2025
…oid logging from the root logger (langchain-ai#364)

## Rationale

- Not using the root logger lets the end user better control logging for
specific packages and modules, e.g. by configuring
`langchain_aws.llms.bedrock` to log at the `ERROR` level, but
`langchain_aws.llms.bedrock` at the `DEBUG` level.
- Using `logger.exception` adds exception info to the [log
record](https://docs.python.org/3/library/logging.html#logrecord-attributes).
This is particularly useful if you want to use a library like
[python-json-logger](https://pypi.org/project/python-json-logger/) or
[structlog](https://github.com/hynek/structlog), where the exception
info could be nicely formatted into an array/object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants