I have Django 1.3 working with Python 2.7 and MySQL 5.5 on Mac OSX Lion...
I'm betting I'm missing something straight forward, but:
I have a simple Django app in development that uses a dictConfig setting
simpler than the default in settings.py:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d
%(thread)d %(message)s'
},
},
'handlers': {
'console':{
'level':'DEBUG',
'class':'logging.StreamHandler',
'formatter': 'verbose'
},
'file':{
'level':'DEBUG',
'class':'logging.FileHandler',
'formatter': 'verbose',
'filename': 'testdjango.log',
},
},
'loggers': {
'testlogger': {
'handlers': ['console','file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
Then later in code that I know is run... (I tried in my app's views.py and
also the backend).. I put something like this:
import logging
logger = logging.getLogger('testlogger')
logger.warn('hello')
logger.info('please appear')
And I just don't see it, neither in the console, nor the file.
I have also tried something like this:
import logging
logger = logging.getLogger('otherlogger')
hdlr = logging.FileHandler('newlogger.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
logger.warn('In settings.py!')
And that doesn't work either, unless I put it right in settings.py.. in
which case it appears 4 times, because, from what I understand, settings.py
gets loaded that many times. But then this doesn't work in the
views.py/backend .. perhaps because the dictConfig gets loaded after
settings.py is run? I don't know.
I'm hoping for someone to give me a heads up about what I'm missing here.
Django's been pretty easy to deal with until I started to look into
logging.
Thanks.
--
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/-/JvmqgFNPMu4J.
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-users?hl=en.