python服务端开发调试日志系统_Python日志和Pydev调试器?

Edit :

Using Liclipse 1.2.1 instead of 1.3.0 or 1.4.0 is working fine. Changelog indicate both Pydev 3.9.1 and Eclipse 4.4.1 updates for 1.3.0. Seems to break logging debug.

Using Liclipse and Pydev debugger (and CPython) with the following code sample, getting that error :

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'

There is no problem without debugging, is the logging module require run environment and will only work on it ?

Here is the code sample used :

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)

And here is my 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]

Thanks

解决方案

same problem with PyCharm.

possible workaround - to comment out pydev_monkey_qt.patch_qt() line in pycharm/helpers/pydev/pydevd.py, for Eclipse it should be located somewhere else

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值