# 日志记录

一些基本的日志记录是通过标准Python[日志记录](https://docs.python.org/3/library/logging.html)模块实现的。

1. 要使用 logs.basicConfig 启用所有 ZOSPy 和其他模块的日志输出：
    ```python
    import logging
       
    logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ```
2. 使用根记录器启用所有ZOSPy和其他模块的日志输出：
    ```python
    import logging

    fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    sh = logging.StreamHandler()
    sh.setFormatter(fmt)
    sh.setLevel(logging.DEBUG)

    logger = logging.getLogger()
    logger.addHandler(sh)
    ```
3. 仅从ZOSPy启用日志输出
    ```python
    import logging

    logging.getLogger('zospy').addHandler(logging.StreamHandler())
    logging.getLogger('zospy').setLevel(logging.INFO)
    ```
