#17680: logging from command line
-------------------------------------+--------------------
Reporter: Brian May <brian@…> | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.3
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+--------------------
The documentation says "Logging is configured immediately after settings
have been loaded. Since the loading of settings is one of the first things
that Django does, you can be certain that loggers are always ready for use
in your project code."
I assume this to be correct for web requests. It also seems to be correct
for the "manage.py shell" interactive shell. It does not seem to work for
command line applications however. For example, if I try to run the
following code:
{{{
#!/usr/bin/env python
from django.core.management import setup_environ
from kgadmin.conf import settings
setup_environ(settings)
import logging
logger = logging.getLogger(__name__)
logger.debug(u"something weent debug")
logger.info(u"something weent info")
logger.error(u"something weent error")
}}}
then logging is not initialized and I get the following message:
{{{
No handlers could be found for logger "__main__"
}}}
To fix this, I have to insert code like the following to force the
settings to become initialized:
{{{
import django.conf
django.conf.settings.LOGGING
}}}
I would have hoped that setup_environ(...) would do all of this, but
apparently not.
This is with python-django 1.3-2ubuntu1.1 running on Ubuntu 11.10
Brian May
--
Ticket URL: <https://code.djangoproject.com/ticket/17680>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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/django-updates?hl=en.