This is what i tried .
In my view.py file ,
import logging
logger = logging.getLogger("mylog")
logging.basicConfig(format='%(name)s:%(levelname)s:%(message)s',level=logging.INFO,datefmt='%d/%m/%y %I:%M:%S')
Then inside a function ,
logger.debug("this is an error")
logger.warning("This is a warning")
print "This is a test line '
I have not touched the settings.py file .its pretty much the same.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
When i run the server , and call the function , nothing happens . no error , nothing .
I just want to see a log line on the console .
Try adding this to handlers:
and in loggers:
The log level could be the same or different – In fact the handler defines the minimum level it will log, while the logger defines the minimum level it will send to handler. If one handler is used by two or more loggers – it should ideally has the lowest level from both loggers.
EDIT: Thanks to @jpic for pointing the loggers section.