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)