espnet3.utils.logging_utils.configure_logging
Less than 1 minute
espnet3.utils.logging_utils.configure_logging
espnet3.utils.logging_utils.configure_logging(log_dir: Path | None = None, level: int = 20, filename: str = 'run.log') → Logger
Configure logging for an ESPnet3 run.
This sets up: : - A root logger with a stream handler (console).
- An optional file handler at log_dir/filename.
- If log_dir/filename already exists, it is rotated to the next available suffix (e.g., run1.log) and a fresh run.log is created.
- Warning capture into the logging system.
Example usage: : ``` ``
<br/>`
<br/>
python
from pathlib import Path
from espnet3.utils.logging_utils import configure_logging
<br/>
logger = configure_logging(log_dir=Path(“exp/run1”), level=logging.INFO)
logger.info(“hello”)
<br/>``
<br/>`
Example log output:
: ``
[babel-t9-28] 2026-02-11 03:57:16 EST (logging_utils.py:376) INFO: [main] hello
``
Example directory tree (when log_dir/filename already exists):
: ``
exp/run1/
├── run.log # new logs (current run)
└── run1.log # rotated older logs
``
* **Parameters:**
* **log_dir** (*Path* *|* *None*) – Directory to store the log file.
If None, only console logging is configured.
* **level** (*int*) – Logging level (e.g., logging.INFO).
* **filename** (*str*) – Log file name when log_dir is provided.
* **Returns:**
Logger instance named “espnet3”.
* **Return type:**
logging.Logger
### Example
```python
>>> from pathlib import Path
>>> logger = configure_logging(log_dir=Path("exp/logs"))
>>> logger.name
'espnet3'