以下代码和yaml配置会从Eclipse / Pydev或命令行中生成警告消息,但不会生成调试消息。在未注释打印语句的情况下,配置字典看起来不错。我想念什么?
setupLogging.py:
#!/usr/bin/env python3
import logging.config
import yaml
def setupLogging():
with open('loggingConfig.yaml', 'rt') as file:
config = yaml.safe_load(file.read())
#print(str(config))
logging.config.dictConfig(config)
if __name__ == "__main__":
setupLogging()
logger = logging.getLogger(__name__)
logger.debug("logger debug")
logger.warning("logger warning")
loggingConfig.yaml:
---
version: 1
disable_existing_loggers: False
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: simple
stream: ext://sys.stdout
root:
handlers: [console]
...