Re: How to display requests for flask app running under cherrypy using WSGI

Flask User <admin-3AnJ/iRYp+RWk0Htik3J/[email protected]> Tue, 13 Sep 2016 20:20:03 -0700 (PDT)
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
I was thinking that by tweaking cherrypy logger or werkzeug, I don't need 
to use middleware (one less dependency), but based on all the examples and 
your response thought it isn't possible without using wsgi middleware. 

I achieved it by using wsgi-request-logger (installing it by pip install 
wsgi-request-logger), the code I used is following.

import cherrypy
from requestlogger import WSGILogger, ApacheFormatter
from logging.handlers import TimedRotatingFileHandler

from api.flask_app import create_app

app = create_app()

handlers = [TimedRotatingFileHandler('logs/access.log', 'd', 7), ]
app_with_log = WSGILogger(app, handlers, ApacheFormatter())
cherrypy.tree.graft(app_with_log, "/")
cherrypy.config.update({
        'engine.autoreload_on': True,
        'log.screen': True,
        'server.socket_port': 8080,
        'server.socket_host': '0.0.0.0',
    })
cherrypy.engine.start()
cherrypy.engine.block()



On Wednesday, September 14, 2016 at 7:41:52 AM UTC+8, Joel Rivera wrote:
>
> On Tue, 13 Sep 2016 16:37:45 -0700 (PDT) 
> Flask User <ad...-3AnJ/iRYp+RWk0Htik3J/[email protected] <javascript:>> wrote: 
>
> > This means using werkzeug or wsgilog kind of middleware with flask? 
> > 
>
> Take a look into: http://blog.joel.mx/posts/cherrypy-as-a-wsgi-server 
>
> Specially the `_with_access_log` function, specifically I'm using 
> https://pypi.python.org/pypi/wsgi-request-logger/. 
> -- 
> Rivera² 
>

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.