Reputation: 1796
Hi I looking for some configuration or flag that allows me to silence the requested pages.
When I run python cherrypy_app.py
and I join to the 127.0.0.1:8080
in the console where I start the cherrypy app show me
127.0.0.1 - - [09/Oct/2014:19:10:35] "GET / HTTP/1.1" 200 1512 "" "Mozilla/5.0 ..."
127.0.0.1 - - [09/Oct/2014:19:10:35] "GET /static/css/style.css HTTP/1.1" 200 88 "http://127.0.0.1:8080/" "Mozilla/5.0 ..."
127.0.0.1 - - [09/Oct/2014:19:10:36] "GET /favicon.ico HTTP/1.1" 200 1406 "" "Mozilla/5.0 ..."
I do not want to show this info. It is possible?
Upvotes: 0
Views: 771
Reputation: 25194
I as far as I remember in my first attempts with CherryPy I had the same desire. So here's a little more to say besides turning off the stdout logging per se.
CherryPy has some predefined environments: staging, production, embedded, test_suite that are defined here. Each environment has its set of configuration. So while developing stdout logging is in fact quite helpful, whereas in production environment it makes no sense. Setting the environment according to the deployment is the correct way to deal configuration in CherryPy.
In your particular case the stdout logging is controlled by log.screen
. It is already disabled in production environment.
Here's the example, but note that setting environment inside your application isn't the best idea. You're better use cherryd
's --environment
for it instead.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cherrypy
config = {
'global' : {
'server.socket_host' : '127.0.0.1',
'server.socket_port' : 8080,
'server.thread_pool' : 8,
# Doing it explicity isn't a recommended way
# 'log.screen' : False
}
}
class App:
@cherrypy.expose
def index(self):
return 'Logging example'
if __name__ == '__main__':
# Better use cherryd (http://cherrypy.readthedocs.org/en/latest/install.html#cherryd)
# for setting the environment outside the app
cherrypy.config.update({'environment' : 'production'})
cherrypy.quickstart(App(), '/', config)
Upvotes: 1