Notes NOD Site Setup
SiteTechNotes1. Problems with stdout / std error
1.1. Summary
When developing Django applications you really need a way to get some logging output. Normally stdout and stderr are available. But, they can get swallowed by mod_python or fcgi. Especially if you use the 'manage.py runserver'. There are supposed to be command line options to specify stdout and stderr but right now they are not always working (and sometimes completely ignored). Other times those options will not work because of the complexity of multi-threaded operations dealing with multiple simultaneous requests.
you could write your own logging implementation or worse force a redirect of sys.stdout and sys.stderr in every view function. It would seem there would be an elligant and simple way to deal with this.
1.2. Logging Solution
From Honza Král on the Django users
in settings.py :
import logging
# configure logging used throughout the application
logging.basicConfig( level=DEBUG and logging.DEBUG or logging.WARNING,
format='%(asctime)s %(levelname)s %(name)s %(message)s',
datefmt='%Y.%m.%d %H:%M:%S',
filename='/tmp/myapp.log',
filemode='a'
)
in code :
import logging
log = logging.getLogger( 'myapp.mymodule' )
log.info( "Some INFO" )
log.error( "...." )
log....
Tags:
Last Modified: 2008-06-03 08:49:22 by Leeland - [ Snip Changes ] [ Wiki History ]

