2013-07-12 7 views
0

Bottle은 파일에 기록 할 nice access_log 출력이 있습니다.파이썬 병 로그에서 stdout을 파일로 보내려면 어떻게해야합니까?

어떻게 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_log에서 아무것도 얻을 수 없다.

+0

stdout 대신 stderr를 시도하십시오. 로그 메시지를 stdout에 쓰는 것은 의심 스럽습니다. – mata

+0

글쎄, 네 말이 맞아. 그러나 그것은 저를 쓸모 없게 만듭니다. 아파치입니다. – bahamat

+1

내장 된 개발 서버를 프로덕션에 사용해서는 안됩니다! 동시에 여러 요청을 처리 할 수도 없습니다. – aychedee

답변

1

보틀이 stderr이 아닌 stdout으로 인쇄됩니다.

log = open('/dev/shm/access_log', 'a') 
with daemon.DaemonContext(stderr=log): 
    run(host='0.0.0.0', port=8080)