-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Log with logging instead of stdout/stderr #1401
Comments
You can tell bottle to be |
Thanks for your answer.
Even with
because it probably still looks for stderr/stdout, even with Do you think we could solve #1104 (comment) by setting
if
We also have the logging of each request (this is maybe present in debug mode only?) which could be useful in
How can it be started except BTW: what is the bottle CLI? Is there a CLI tool available in bash: |
PS: the really interesting application would be to log in a file the uncaught exceptions in routes:
Here the exception in |
Request logging is the job of the HTTP server, not bottle. Exceptions are logged to
Yes. Bottle is a WSGI framework, you do not need to use
This was all discussed in the other issue already.
Calling |
Thanks @defnull, I read the code and I now understand that "request logging" is out of scope of bottle. Here is a nice way to do it: python bottle always logs to console, no logging to file. About uncaught exceptions:
Here https://github.com/bottlepy/bottle/blob/master/bottle.py#L1007 we see that the traceback is written to Even if I use another server, or if I subclass I don't see how another server than the default WSGIRefServer could expose |
If you feel adventurous, you can also replace |
Do not bother with |
Thanks @defnull. The following code seems to work, is it what you were thinking about? PS: I posted a question about this here: https://stackoverflow.com/questions/74130588/redirect-python-bottle-stderr-stdout-to-logging-logger-or-more-generally-usin
|
@josephernest as defnull comments, you can use different application servers, like uwsgi, gunicorn... where all this is already covered. https://uwsgi-docs.readthedocs.io/en/latest/Logging.html just change your run() to: |
@agalera I am in a context where I need to keep the lowest number of dependencies. |
Is there an option to make
bottle
use the Python built-inlogging
package instead of stderr/stdout?Here is a basic example, would you see how to redirect the
"Bottle v0.12.23 server starting up (using WSGIRefServer())... Listening on http://localhost:8080/ Hit Ctrl-C to quit."
information tologging
, as well as the different requests logs?It would also have the benefit to avoid the issue of not being able to use
bottle
withpythonw
(which has no stderr/stdout), as seen in #1104 (comment).The text was updated successfully, but these errors were encountered: