up:: [[Python MOC]]
# Setting Up Hierarchical Loggers In Python
In Python, you can set up hierarchical loggers that log to the same place, but show the structure of the modules involved. This should be used in concert with a dynamic root logger in the calling code. In modules below it, especially if they're libraries, you would set up the hierarchy with `__main__.<module>` with `.` signifying each level of the hierarchy.
**Note:** For logging with AWS services, you do not want to set the root logger to `DEBUG` because you'll get a ton of useless logs. Instead, get a logger under the root logger (like `"__main__"`) and set that logger's level (see [[Setting Up Hierarchical Loggers In Python#^d2zh3m|here]])
## Example
main_script.py
```python
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO) # or whatever level
```
main_script.py for AWS use cases ^d2zh3m
```python
import logging
logger = logging.getLogger("__main__")
logger.setLevel(logging.INFO)
```
helper_module.py
```python
import logging
logger = logging.getLogger("__main__.helper")
```
## Source
https://stackoverflow.com/questions/50714316/how-to-use-logging-getlogger-name-in-multiple-modules