I find I had to make a catch all handler for logging to work:
in settings.py
...
'loggers': {
'': { # catch all logger
'handlers': ['console'],
'level': 'WARNING', # re-defined in settings_dev
'propagate': True
},
...
And in files I need logging I do:
import logging
logging.basicConfig(format='%(levelname)s
%(module)s@%(filename)s@%(funcName)s@%(lineno)d: %(message)s',
level=logging.DEBUG)
...
logging.debug('test')
...
-----Original Message-----
From: Gelonida N
Sent: Wednesday, April 18, 2012 4:41 AM
To: django-users@googlegroups.com
Subject: 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
Daniel Sokolowski
Web Engineer
Danols Web Engineering
http://webdesign.danols.com/
Office: 613-817-6833
Fax: 613-817-4553
Toll Free: 1-855-5DANOLS
Kingston, ON K7L 1H3, Canada
Notice of Confidentiality:
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review re-transmission dissemination or other use of or taking
of any action in reliance upon this information by persons or entities other
than the intended recipient is prohibited. If you received this in error
please contact the sender immediately by return electronic transmission and
then immediately delete this transmission including all attachments without
copying distributing or disclosing same.
--
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+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.