Note that there are some explanatory texts on larger screens.

plurals
  1. POPython dictionary ValueError while importing logging configuration
    text
    copied!<p>I've searched through google and found only answers regarding Django and it's urls. My problem is similar but concerns logging issues and I cannot cope with that. </p> <p>I used <a href="http://docs.python.org/2/howto/logging.html#logging-advanced-tutorial" rel="nofollow">Advanced Logging Tutorial</a> and <a href="http://docs.python.org/2/howto/logging-cookbook.html#" rel="nofollow">Logging Cookbook</a> as well as <a href="http://docs.python.org/2/library/logging.config.html#module-logging.config" rel="nofollow">logging.conf description</a></p> <p>and always get the error below after running "python logger.py":</p> <pre><code>Traceback (most recent call last): File "logger.py", line 5, in &lt;module&gt; logging.config.dictConfig('logger-dict.conf') File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig dictConfigClass(config).configure() File "/usr/lib/python2.7/logging/config.py", line 380, in __init__ self.config = ConvertingDict(config) ValueError: dictionary update sequence element #0 has length 1; 2 is required </code></pre> <p><strong>logger.py</strong></p> <pre><code>import logging import logging.config logging.config.dictConfig('logger-dict.conf') logger = logging.getLogger('basic') logger.debug('debug message') logger.info('info message') logger.warn('warn message') logger.error('error message') logger.critical('critical message') </code></pre> <p><strong>logger-dict.conf</strong></p> <pre><code>LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'simple': { 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s', 'datefmt': '%d/%m/%Y %H:%M:%S %Z', }, }, 'handlers': { 'console':{ 'level':'DEBUG', 'class':'logging.StreamHandler', 'formatter': 'simple' }, 'file':{ 'level': 'WARNING', 'class': 'logging.handlers.RotatingFileHandler', 'formatter': 'simple', 'mode': 'a', 'filename': './logs/logconfig.log', 'maxBytes': '1048576', 'backupCount': '5', }, }, 'loggers': { 'basic': { 'handlers':['file'], 'propagate': True, 'level':'INFO', }, } } </code></pre> <p>I have been trying to solve the issue with the answers regarding Django but no success for now.</p> <p><strong>EDIT:</strong></p> <p>After a comment below I understood that if to put a dictionary somewhere it is better to put it into *.py file instead of *.conf.</p> <p>But is there an EASY way (not reading file line by line) to use *.conf file with python dictionary inside?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload