Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write log messages to stderr #5853

Closed
finswimmer opened this issue Jan 20, 2021 · 1 comment
Closed

write log messages to stderr #5853

finswimmer opened this issue Jan 20, 2021 · 1 comment
Labels
question issue where a "fix" on the SQLAlchemy side is unlikely, hence more of a usage question

Comments

@finswimmer
Copy link

Hello everyone.

Describe the bug
At the moment sqlalchemy prints out messages to stdout by default, e.g when setting echo=True in create_engine. This is also stated out clearly in docs.

Messages by sqlalchemy are usually useful for diagnostics. According to https://www.gnu.org/software/libc/manual/html_node/Standard-Streams.html it is recommended to use stderr for such a purpose. This becomes more important, if the program, in which sqlalchemy is used, writes its output to stdout, as there is no (easy) way which messages are a result of the program and which one are debug messages by sqlalchemy.

Expected behavior
Messages by sqlalchemy should be printed out to stderr by default, or at least this should be configurable.

Is this the correct line that is responsable for the current behavior?

fin swimmer

@finswimmer finswimmer added the requires triage New issue that requires categorization label Jan 20, 2021
@zzzeek zzzeek added question issue where a "fix" on the SQLAlchemy side is unlikely, hence more of a usage question and removed requires triage New issue that requires categorization labels Jan 20, 2021
@zzzeek
Copy link
Member

zzzeek commented Jan 20, 2021

hey there -

echo=True is not intended as a production-level logging facility, it's used for when you're in a Python console and want to see SQL generated quickly.

For production-quality logging, you should use Python's standard logging system. Configuration of SQLAlchemy's logging in terms of this system is described at: https://docs.sqlalchemy.org/en/13/core/engines.html#configuring-logging

@CaselIT CaselIT closed this as completed Jan 26, 2021
@sqlalchemy sqlalchemy locked and limited conversation to collaborators Jan 26, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question issue where a "fix" on the SQLAlchemy side is unlikely, hence more of a usage question
Projects
None yet
Development

No branches or pull requests

3 participants