Answer the question
In order to leave comments, you need to log in
Django logging?
settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/path/to/django/debug.log',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
import logging
logger = logging.getLogger(__name__)
def show_article(request,url):
article=Articles.objects.all()
logger.debug(article)
Answer the question
In order to leave comments, you need to log in
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/path/to/django/debug.log',
},
},
'loggers': {
'news': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
The `__name__` variable denotes the name of the current module in the project context, i.e. = "yourapp.views"
And you only have logging enabled for `django.*`.
To enable for your module add loggers[yourapp]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question