-
-
Notifications
You must be signed in to change notification settings - Fork 756
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
Document how to configure the connexion logger to see internal exceptions in logs #1798
Comments
Hi @lotzej The default exception handlers registered in Connexion should log any errors by default. I cannot reproduce the lack of a stack trace, both when running an application, or when running a test. Connexion follows logging best practices, so you should just be able to get access to the connexion logger using: import logging
connexion_logger = logging.getLogger("connexion") Could you confirm if that addresses your use case? Then we can add this to the documentation. |
Yes, accessing the logger like this and adding a handler to it that goes to standard output fixes the issue. Without that, I don't see a stack trace. Would be good to document that - people used to flask would typically already have code to setup the flask app logger, and that worked previously. With Connexion 3.0, the exception logs go elsewhere, so people might miss that. |
I might be doing something wrong, but if I don't touch the logging configuration in any way and just run tests, I don't see any exception traces logged. Logging best practices says that warning level and above should go to stderr by default for a library. |
I see we do set the logging level in our tests. I'm not sure why it's needed though. Connexion doesn't set any logging configuration, so I would expect the default level to be |
You're right actually - without logging configuration it shows the warnings/exceptions automatically. We had reconfigured the logging setting for flask in the previous version, and that removed them. It was a major headache, as that's easy to miss when upgrading to connexion 3.0. Previously the errors were showing (by flask) - now they were not. |
Description
Being used to Flask, we usually configured the default handler for flask's
app.logger
and that enabled us to see detailed information, including stack trace, for exceptions raised in a view function. This is very helpful after an internal server error occurred, to dig down to the cause in the logs.With Connexion 3.0, the default exception handler uses connexion's own logger, and if that does not have a handler registered, all we can see is an internal server error response with no details. Especially in development this is very annoying, as the root cause cannot be found easily. This also applies to tests.
Expected behaviour
Enable logging to stderr for at least exception-level, or document clearly how to add a handler to connexion's own logger for this purpose.
Actual behaviour
No error details visible.
Steps to reproduce
Write any code in a view handler that raises an exception and run a test. Details of the actual error cannot be found by default.
The text was updated successfully, but these errors were encountered: