主文件中:
```python
# Level: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
import logging
logging.basicConfig(level=logging.DEBUG,
filename="mylog.log",
format='%(asctime)s %(levelname)s %(filename)s %(funcName)s %(lineno)d %(message)s',
filemode='w')
logger = logging.getLogger(__name__)
# logger.getLogger("module_name").setLevel(logging.CRITICAL)
```
在其他文件:
```py
import logging
logger = logging.getLogger(__name__)
```