문제

Bottle has nice access_log output that I want to log to a file.

How do I use daemon and put that in a file somewhere?

#!/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)

It backgrounds and bottle works but I get nothing in /dev/shm/access_log.

도움이 되었습니까?

해결책

Bottle prints to stderr, not stdout.

log = open('/dev/shm/access_log', 'a')
with daemon.DaemonContext(stderr=log):
  run(host='0.0.0.0', port=8080)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top