Django logging not showing argument
I have this line in a custom django-admin command:
logger.info("%d records updated", records_updated)
When I run the command, the log file and console output show what I would expect:
[2011-09-02 03:49:31,405] INFO::(27041 140698227433576)::update_records - 5 records updated
However, the email to the admin shows
INFO: %d records updated #This is the subject and body of the email the admin receives
This is my logging info in the settings.py file:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'default': {
'format': '[%(asctime)s] %(levelname)s::(%(process)d 开发者_运维问答%(thread)d)::%(module)s - %(message)s'
},
},
'handlers': {
'email_admins': {
'level': 'INFO',
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
'formatter': 'default',
},
'admin_console': {
'level':'INFO',
'class':'logging.StreamHandler',
'formatter': 'default'
},
'null': {
'level':'DEBUG',
'class':'django.utils.log.NullHandler',
'formatter': 'default',
},
'file_handler': {
'level': 'DEBUG',
'formatter':'default',
'class': 'logging.handlers.TimedRotatingFileHandler',
'filename':'logs/Project_log',
'when':'midnight',
'interval':1,
},
'request_handler': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': 'logs/django_request.log',
'maxBytes': 1024*1024*5, # 5 MB
'backupCount': 5,
'formatter':'default',
},
},
'loggers': {
'': {
'handlers': ['email_admins', 'file_handler', 'admin_console'],
'level': 'DEBUG',
'propagate': True,
},
'django': {
'handlers':['null'],
'propagate': True,
'level':'INFO',
},
'django.request': {
'handlers': ['email_admins', 'request_handler'],
'level': 'ERROR',
'propagate': False,
},
}
}
Any feedback appreciated.
logger.info("%d records updated" % records_updated)
Maybe u should write like this?
精彩评论