如何使python瓶子日志将其标准输出发送到文件?
瓶子有很好的如何使python瓶子日志将其标准输出发送到文件?,python,logging,bottle,python-daemon,Python,Logging,Bottle,Python Daemon,瓶子有很好的access\u log输出,我想记录到一个文件中 如何使用daemon并将其放在某个文件中 #!/usr/bin/env python from bottle import route, run import daemon @route('/foo') def foo(): return template('bar') log = open('/dev/shm/access_log', 'a') with daemon.DaemonContext(stdout=log):
access\u log
输出,我想记录到一个文件中
如何使用daemon
并将其放在某个文件中
#!/usr/bin/env python
from bottle import route, run
import daemon
@route('/foo')
def foo():
return template('bar')
log = open('/dev/shm/access_log', 'a')
with daemon.DaemonContext(stdout=log):
run(host='0.0.0.0', port=8080)
它的背景和瓶子工作正常,但我在
/dev/shm/access\u log
中什么也没有得到,瓶子打印到stderr
,而不是stdout
log = open('/dev/shm/access_log', 'a')
with daemon.DaemonContext(stderr=log):
run(host='0.0.0.0', port=8080)
尝试stderr而不是stdout。我怀疑它是在给stdout写日志消息。嗯,你是对的。但这对我来说几乎一文不值。是Apache。内置的开发服务器无论如何都不应该用于生产!它甚至不能同时满足多个请求。@aychedee:为什么你认为我在生产中使用它?