# Logging Configuration

QAIRT provides a configurable logging framework with area-based loggers, custom log levels,
and both console and file handlers. All configuration can be done programmatically – there is
no need to edit YAML files.

## Log Levels

QAIRT extends Python’s standard logging levels with two additional levels:

| Level | Value | Description |
| --- | --- | --- |
| `CRITICAL` | 50 | Fatal errors only |
| `ERROR` | 40 | Errors that prevent normal operation |
| `WARNING` | 30 | Unexpected situations that may require attention |
| `INFO` | 20 | General progress messages (default for most areas) |
| `DEBUG` | 10 | Detailed diagnostic information |
| `TRACE` | 5 | Extremely detailed tracing (below DEBUG) |
| `DISABLED` | 51 | Suppresses all output from a logger |

## Logger Areas

Each QAIRT subsystem has its own named logger. The table below lists the default areas and
their levels:

| Logger Name | Default Level |
| --- | --- |
| `qairt.compile` | INFO |
| `qairt.convert` | WARNING |
| `qairt.execute` | WARNING |
| `qairt.transform` | WARNING |
| `qairt.model` | WARNING |
| `qairt.profile` | WARNING |
| `qairt.optimizer.onnx` | WARNING |
| `GenAIBuilder.HTP` | WARNING |
| `GGUFBuilder.HTP` | WARNING |

## Setting the Global Log Level

The `QAIRT_LOG_LEVEL` environment variable overrides the level for **all** loggers. Set it
before importing any QAIRT module:

export QAIRT_LOG_LEVEL=DEBUG
    Copy to clipboard

Or set it within Python before the first QAIRT import:

import os
    os.environ["QAIRT_LOG_LEVEL"] = "DEBUG"
    
    from qairt.gen_ai_api.gen_ai_builder_factory import GenAIBuilderFactory  # loggers pick up DEBUG
    Copy to clipboard

## Programmatic Configuration

For finer control, use `QAIRTLogger` to
adjust individual logger areas at runtime.

### Change the level of a single area

import logging
    from qti.aisw.tools.core.utilities.qairt_logging import QAIRTLogger, LogAreas
    
    # Register (or retrieve) the area, then set its level
    area = LogAreas.register_log_area("qairt.compile")
    QAIRTLogger.set_area_logger_level(area, logging.DEBUG)
    Copy to clipboard

### Change the level of all areas

from qti.aisw.tools.core.utilities.qairt_logging import QAIRTLogger
    
    QAIRTLogger.set_level_for_all_areas("DEBUG")
    Copy to clipboard

### Use case: View only compile log messages

Silence every area except `qairt.compile`:

from qti.aisw.tools.core.utilities.qairt_logging import QAIRTLogger, LogAreas
    
    # Disable all areas first
    QAIRTLogger.set_level_for_all_areas("DISABLED")
    
    # Then enable just the compile area
    area = LogAreas.register_log_area("qairt.compile")
    QAIRTLogger.set_area_logger_level(area, "INFO")
    Copy to clipboard

### Use case: Enable verbose logging for Gen AI Builder

from qti.aisw.tools.core.utilities.qairt_logging import QAIRTLogger, LogAreas
    
    for name in ["GenAIBuilder.HTP", "qairt.compile", "qairt.transform"]:
        area = LogAreas.register_log_area(name)
        QAIRTLogger.set_area_logger_level(area, "DEBUG")
    Copy to clipboard

### Use case: Redirect logs to a file

Write all logs from an area prefix to a file instead of the console:

from qti.aisw.tools.core.utilities.qairt_logging import QAIRTLogger
    
    # Redirect all qairt.optimizer.onnx logs to /tmp/optimizer_logs/
    QAIRTLogger.redirect_logger_to_file(
        logger_name="qairt.optimizer.onnx",
        log_file_path="/tmp/optimizer_logs/",
    )
    Copy to clipboard

The prefix is matched dot-bounded: `"qairt.optimizer.onnx"` also redirects
`"qairt.optimizer.onnx.passes"`.
The log filename is determined by the handler config (default: `user_info.log`).

Last Published: May 26, 2026

[Previous Topic
Recommendations](https://docs.qualcomm.com/bundle/publicresource/80-87189-2/topics/qairt-resource-profiler.md) [Next Topic
API Documentation](https://docs.qualcomm.com/bundle/publicresource/80-87189-2/topics/api.md)