i want able override console log level in settings file. read django logging document, i'm having trouble making logging want. documentation assures me that:
"from django 1.5 forward, project’s logging configuration merged django’s defaults, hence can decide if want add to, or replace existing configuration. override default configuration, set disable_existing_loggers key true in logging dictconfig. alternatively can redefine or of loggers."
so tried adding following settings.py:
logging = { 'version': 1, 'disable_existing_loggers': false, 'handlers': { 'console':{ 'level': 'debug', }, }, } ...but exception:
<snip> file "/usr/lib/python2.7/logging/config.py", line 575, in configure '%r: %s' % (name, e)) valueerror: unable configure handler 'console': 'nonetype' object has no attribute 'split' fair enough. seems want whole configuration block. tried thought simplest console logger config:
logging = { 'version': 1, 'disable_existing_loggers': true, 'formatters': { 'simple': { 'format': '%(levelname)s %(message)s' }, }, 'handlers': { 'console':{ 'level': 'info', 'class': 'logging.streamhandler', 'formatter': 'simple' }, }, 'loggers': { 'default': { 'handlers': ['console'], 'level': 'info', 'filters': [] } } } my intention set log-level info, still see bunch of debug messages, , string myformatter doesn't appear in of them anyway.
finally, blind optimism, attempted this:
from django.utils.log import default_logging default_logging['handlers']['console']['level'] = 'info' i must missing quite obvious here.
btw, i'm using django 1.5.1.
answering own question here, ended going following in settings.py file:
import logging logging.basicconfig( level = logging.info, format = " %(levelname)s %(name)s: %(message)s", )
Comments
Post a Comment