Reputation: 454
I have a logging .yaml config file (parital):
handlers:
console:
class: logging.StreamHandler
stream: ext://sys.stderr
formatter: basic
console_file:
class: logging.handlers.RotatingFileHandler
filename: bvbot_general.log
maxBytes: 20000000
backupCount: 3
encoding: utf-8
formatter: basic
loggers:
general:
handlers: [console]
level: DEBUG
propagate: False
general_file:
handlers: [console_file]
level: DEBUG
propagate: True
root:
handlers: [console]
level: INFO
Individually the loggers 'general' and 'general_file' work as expected. But, if I add the 'console_file' handler to logger 'general', I only get output to console and not also to file as anticipated:
loggers:
general:
handlers: [console, console_file]
level: DEBUG
propagate: False
Upvotes: 1
Views: 395
Reputation: 662
How do get your logger? Works fine for me with following code:
import os
import logging.config
import yaml
# Loading from logging.yaml
# ...
logger = logging.getLogger('general')
logger.info('hello')
Upvotes: 1