I've been breaking my head over creating a simple logfile within my django application. I've tried applying this question, as well as the examples on the docs, but it simply doesn't seem to work and I don't know what is going wrong.
My current logfile, second example straight from the doc:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
},
}
The docs states the following:
"this config only sends messages of level INFO or higher to the console"
In my understanding, if I were to place this into my home.view.py
file...
import logging
log = logging.getLogger(__name__)
log.debug("Hey there it works!!")
log.info("Hey there it works!!")
log.warn("Hey there it works!!")
log.error("Hey there it works!!")
...i should get the info
, the warn
and the error
message printed to my console, whenever a call is made to home.views.py
, which I thought happens when I visit the correct url.
This appears to be false. It seems however that only warn
and error
is printed, and only when I run manage.py collectstatic
.
WARNING:home.views:Hey there it works!!
ERROR:home.views:Hey there it works!!
I want to receive the log messages in console, whenever I visit a webpage that's rendered from home.views.py
. How do I do this?