[Twisted-Python] running twisted with supervisord -- logging question

Christopher Armstrong radix at twistedmatrix.com
Sat Aug 23 23:56:50 MDT 2014


On August 23, 2014 at 6:50:32 PM, Jonathan Vanasco (twisted-python at 2xlp.com) wrote:
Christopher-

Thanks for the insight.  I was stupid and didn't include my code.

I don't actually want supervisor to handle the logging.  I wanted to have this app's logs in /var/log/myapp-twisted/twisted.log

I just can't figure out how to make this happen.  i've been playing with different permutations of twistd commands, redirect_stderr and stdout_logfile, and haven't found the right balance

the actual logging calls are just to python's logger ( `import logging` ; logging.getLogger(), log.debug(), etc)

---------
[program:myapp-twisted]
priority=100
process_name=%(program_name)s
autostart=true
autorestart=true
stopsignal=QUIT
redirect_stderr = false
stdout_logfile = /var/log/myapp-twisted/twisted.log
directory = /var/www/sites/myapp-svn_tag-current_production/daemon/twisted
environment = PATH="/var/www/sites/myapp-virtualenv/bin:$PATH"
command = /var/www/sites/myapp-virtualenv/bin/twistd -y controller-production.tac --pidfile /tmp/myapp-twisted.pid
----------



You’re seemingly contradicting yourself: you say you don’t want supervisor to handle logging, but the supervisor configuration you've shown is handling the logging, by routing its stdout to /var/log/myapp-twisted/twisted.log (which I think is a fine thing to do, fwiw).

If this isn’t working, then the problem is probably in your python code, not the supervisor configuration: are you sure it’s writing logs to stdout? Again, we need to see your actual python code (or a minimal reproducible example) to diagnose this.

Since you’re not using twisted’s logging system, I really can’t make any guesses here. If you *were* using twisted’s logging system, I would point out that you should add “-l -“ to your twistd command line in that supervisor config, to make twisted’s logs go to stdout as well (maybe you want to do this even if your application isn’t using twisted’s log system, so that both the logs of twisted and of your application are going to the same place).


-- 
Christopher Armstrong
http://twitter.com/radix
http://wordeology.com/






On Aug 22, 2014, at 11:50 PM, Christopher Armstrong wrote:


On August 22, 2014 at 6:52:02 PM, Jonathan Vanasco (twisted-python at 2xlp.com) wrote:

hoping someone can answer this question- 

i can't seem to get my logging right while using supervisord 

i'm not using twisted logging, just the regular python logging infrastructure. 

the two end-results I've had: 

- everything double-logs into twistd.log & /var/log/supervisor.log 
- anything this is `print`'ed appears in my twistd.log , but none of the `log.debug()` lines appear 

the end result I want, is for debug info from the twisted process to be recorded in a single file 


I prefer to use



twistd -n -l - ...



passing ‘-' to -l means “log to stdout”.



Without your code, we can’t know how you’re configuring python logging, and what may be wrong with it. This should be the baseline for using twistd with supervisor if you want to let supervisor handle logging. FYI, you can configure supervisor to put the output in a different file than /var/log/supervisor.log, too.



-- 
Christopher Armstrong
http://twitter.com/radix
http://wordeology.com/

_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

// Jonathan Vanasco

c. 646.729.6436  |  415.501.9815
e. jonathan at 2xlp.com
w. http://findmeon.com/user/jvanasco 
linkedin. http://linkedin.com/in/jonathanvanasco
blog. http://destructuring.net

_______________________________________________  
Twisted-Python mailing list  
Twisted-Python at twistedmatrix.com  
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20140824/02a6907b/attachment-0002.html>


More information about the Twisted-Python mailing list