This is not the correct way to configure the root logger. This configures the logger named "root", which is a child of the actual root logger. The effect is that logger = logging.getLogger("my_logger") does not use the configuration from the JSON (since "my_logger" is not a child of "root", but of the actual root logger, which has not been configured).
|
"loggers": { |
|
"root": { |
|
"level": "DEBUG", |
|
"handlers": [ |
|
"stderr", |
|
"file" |
|
] |
|
} |
|
} |
The root logger uses a separate root key (source), so the correct JSON would be
"loggers": {},
"root": {
"level": "DEBUG",
"handlers": [
"stderr",
"file"
]
}
(the empty "loggers" key can probably be skipped).
This is not the correct way to configure the root logger. This configures the logger named "root", which is a child of the actual root logger. The effect is that
logger = logging.getLogger("my_logger")does not use the configuration from the JSON (since"my_logger"is not a child of"root", but of the actual root logger, which has not been configured).VideosSampleCode/videos/135_modern_logging/logging_configs/2-stderr-json-file.json
Lines 39 to 47 in b6fe3c8
The root logger uses a separate
rootkey (source), so the correct JSON would be(the empty
"loggers"key can probably be skipped).