You need to initialize logging in the WSGI hook file, because the settings are lazily loaded. In other words you could start logging before the logger got instantiated.
I usually write a separate module with my logging code in it and call it in the WSGI hook file. I also found that using the logging config file mechanism didn't work correctly, so dynamically set up logging. Also don't put the logs in the /var/log path as root or adm are usually the only users that can write to it. In production we use an NFS mount for all logs and in testing I put the logs in the Django project environment. If you are using daemon mode with mod_wsgi the logs will be written out with that user so your files need to all be set to that user also. ~Carl On Mon, Nov 29, 2010 at 8:52 AM, [email protected] <[email protected]> wrote: > I know that Django 1.3 adds Python logging (finally), but I'm using 1.2, for > the moment. > > I attempted to initialize logging in setup.py, but found that log files were > being created with root privs. The two that are www-data I did by hand: > > -rw-r----- 1 root 0 Nov 28 21:03 tbp_dc.log > -rw-r----- 1 www-data 548580 Nov 28 21:03 tbp_dc.log.1 > -rw-r--r-- 1 www-data 40651 Nov 21 20:50 tbp_dc.log.2.gz > > So, it seems that, until Django's all running (i.e. handling an actual > request?) it's running as root. > > Then, when it switches to www-data, I can't write to the log files. > > Django 1.3 handles initialization of loggers in the Settings class > initialization in django.conf.__init__.py but I'm a little unclear as to > exactly when this Settings() object is created. > > If the user's still root when this is called, Django 1.3 has the same problem > I have; the logs won't actually be writable. > > Does anyone have any insight as to where this initialization can safely be > done i.e. when I've already switched to being www-data? > > Thanks, > > S > aka/ssteinerX > aka/Steve Steiner > > > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/modwsgi?hl=en. > > -- ------------------------------------------------------------------------------- Carl J. Nobile (Software Engineer) [email protected] ------------------------------------------------------------------------------- -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
