Edit:Python Logging und Pydev Debugger?
Liclipse Mit 1.2.1 statt 1.3.0 oder 1.4.0 funktioniert gut. Changelog zeigt Pydev 3.9.1 und Eclipse 4.4.1 Updates für 1.3.0 an. Scheint das Logging-Debug zu unterbrechen.
Mit Liclipse und Pydev Debugger (und CPython) mit dem folgenden Codebeispiel, dass Fehler bekommen:
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'
Es gibt kein Problem, ohne das Debuggen ist das Protokollierungsmodul erfordern Umgebung gestartet werden und wird nur arbeite daran ?
Hier ist der Code Probe verwendet:
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)
Und hier ist mein 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]
Dank
Vielen Dank, das war für mich mit PyCharm 4.0.5. – EM0
Danke von mir auch - es hat mit PyCharm 4.5.2 funktioniert. – rettops
Danke auch für mich gearbeitet ... mit 'Eclipse' und' Liclipse' Eclipse Mars:/home/ /.p2/pool/plugins Liclipse: /opt/liclipse/plugins/org.python.pydev_4.3.0. 201508181931/pysrc/pydevd.py –