使用Liclipse 1.2.1而不是1.3.0或1.4.0工作正常。更新日誌表明1.3.0的Pydev 3.9.1和Eclipse 4.4.1更新。似乎打破日誌記錄調試。
使用Liclipse和PyDev調試(與CPython的)用下面的代碼示例,收到這個錯誤:
logging.config.dictConfig(config)
File "C:\Python27\lib\logging\config.py", line 794, in dictConfig
dictConfigClass(config).configure()
File "C:\Python27\lib\logging\config.py", line 576, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'console': 'DictConfigurator' object has no attribute 'startswith'
有沒有調試沒有問題,是記錄模塊需要運行環境,不僅會在...上下功夫 ?
這裏是所使用的代碼示例:
import logging.config
import yaml
def setup_logging():
default_path = 'logger.conf'
default_level = logging.DEBUG
if os.path.exists(default_path):
with open(default_path, 'rt') as f:
config = yaml.load(f.read())
logging.config.dictConfig(config)
else:
logging.basicConfig(level=default_level)
這裏是我的logger.conf:
version: 1
disable_existing_loggers: False
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
lineInfo:
format: "%(asctime)s - Line: %(lineno)d - %(name)s - %(levelname)s - %(message)s"
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: lineInfo
stream: ext://sys.stdout
debug_file_handler:
class: logging.handlers.RotatingFileHandler
level: DEBUG
formatter: lineInfo
filename: logs/debug.log
maxBytes: 10485760 # 10MB
backupCount: 10
encoding: utf8
info_file_handler:
class: logging.handlers.RotatingFileHandler
level: INFO
formatter: simple
filename: logs/info.log
maxBytes: 10485760 # 10MB
backupCount: 10
encoding: utf8
error_file_handler:
class: logging.handlers.RotatingFileHandler
level: ERROR
formatter: simple
filename: logs/errors.log
maxBytes: 10485760 # 10MB
backupCount: 10
encoding: utf8
root:
level: DEBUG
handlers: [console, info_file_handler, error_file_handler, debug_file_handler]
感謝
非常感謝,PyCharm 4.0.5對我來說非常有用。 – EM0 2015-03-27 20:06:50
也感謝我 - 它使用PyCharm 4.5.2。 – rettops 2015-07-06 03:21:42
謝謝你也爲我工作......使用'Eclipse'和'Liclipse' Eclipse Mars:/ home/ /.p2/pool/plugins Liclipse:/opt/liclipse/plugins/org.python.pydev_4.3.0。 201508181931/pysrc/pydevd.py –
2015-11-12 12:33:26