Re: Logging works from 'manage.py shell', not from app
On 04/13/2012 07:41 PM, Jeff Blaine wrote:
> Hi all. I'm stumped on something. Using logging via 'manage.py shell' is
> working as expected. Using it in the webapp generates zero data and
> zero errors.
I'm not sure whether this is your problem, but please note, that logging
to a log file is not a good idea for django, which might spawn multiple
processes.
logging to log files works only from multiple threads (all spanweed by
the same process)
For very first tests you could use a stdout / stderr log handler or
lateron a socket logger.
>
> NOTE: /var/log/hostdb.log is WORLD WRITABLE (in order to dodge any
> permissions errors right now while debugging this)
>
> My logging settings are as follows:
>
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': True,
> 'formatters': {
> 'verbose': {
> 'format': '%(levelname)s %(asctime)s %(module)s %(process)d
> %(thread)d %(message)s'
> },
> 'simple': {
> 'format': '%(levelname)s %(message)s'
> }
> },
> 'handlers': {
> 'console': {
> 'level':'DEBUG',
> 'class':'logging.StreamHandler',
> 'formatter': 'verbose'
> },
> 'logfile': {
> 'level': 'DEBUG',
> 'class': 'logging.handlers.WatchedFileHandler',
> 'formatter': 'verbose',
> 'filename': '/var/log/hostdb.log',
> 'mode': 'a'
> }
> },
> 'loggers': {
> 'django.request': {
> 'handlers': ['logfile', 'console'],
> 'level': 'DEBUG'
> }
> }
> }
>
> For example, the following works fine (shows up in /var/log/hostdb.log):
>
> python manage.py shell
>>> import logging
>>> l = logging.getLogger('django.request')
>>> l.info('this is info!')
>
> Yet I get absolutely nothing logged when a click through pages of the
> app itself.
>
> Any ideas?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/TKIfqpwWZcUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home