如何在没有屏幕记录的情况下运行cherrypy应用程序? [英] How run cherrypy app without screen logging?

查看:54
本文介绍了如何在没有屏幕记录的情况下运行cherrypy应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一些配置或标志,使我可以使请求的页面静音.

Hi I looking for some configuration or flag that allows me to silence the requested pages.

当我运行 python cherrypy_app.py 时,我加入了启动cherrypy应用程序的控制台中的 127.0.0.1:8080

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:3​​5]"GET/HTTP/1.1" 200 1512""Mozilla/5.0 ..."127.0.0.1--[09/Oct/2014:19:10:3​​5]"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:3​​6]"GET/favicon.ico HTTP/1.1" 200 1406""Mozilla/5.0 ..."

我不想显示此信息.有可能吗?

I do not want to show this info. It is possible?

推荐答案

据我对CherryPy的初次尝试,我有同样的愿望.因此,除了关闭stdout日志记录本身以外,还有更多要说的话.

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具有一些预定义的环境:分期,生产,嵌入式,在此处此处.每个环境都有其配置集.因此,尽管开发标准输出日志记录实际上很有帮助,但是在生产环境中却没有任何意义.根据部署设置环境是在CherryPy中进行配置的正确方法.

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.

在您的特定情况下,标准输出日志记录由 log.screen 控制.在生产环境中已将其禁用.

In your particular case the stdout logging is controlled by log.screen. It is already disabled in production environment.

这里是示例,但是请注意,在应用程序内部设置环境并不是最好的主意.您最好使用 cherryd -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)

这篇关于如何在没有屏幕记录的情况下运行cherrypy应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆