Configure logging
DEFAIR reports what it is doing through log messages.
Prerequisites
No. 1 An active DEFAIR environment
Use the environment from Install DEFAIR. Setting
up logging from Python needs no satellite data. To run the command-line
examples, also prepare workflow.yaml and its inputs, as described in
Create a workflow file.
Configure the log level
From Python, set the level once at the start of your program:
from defair.logging import setup_logging
# Human-readable output
setup_logging(log_level="INFO")
# JSON output for log aggregation systems
setup_logging(log_level="DEBUG", json_output=True)
# Per-module log levels
setup_logging(
log_level="WARNING",
module_levels={
"defair_data": "DEBUG", # Verbose for data operations
"defair_ops": "INFO", # Standard for transformations
}
)
WARNING shows only problems. INFO adds one line per step: which
reader was chosen, what is being read, what was written. DEBUG shows
everything.
On the command line the same settings are options of defair itself,
and they go before the command:
defair --log-level DEBUG run --config workflow.yaml
defair --log-json run --config workflow.yaml
defair --log-module-level "defair_data:DEBUG,defair_ops:INFO" run --config workflow.yaml
Each option can also be set with an environment variable:
DEFAIR_LOG_LEVEL, DEFAIR_LOG_JSON and
DEFAIR_LOG_MODULE_LEVEL. Every message from one defair command
carries the same short correlation ID, so the lines of one run can be
picked out of a shared log.
What to do next
Follow Run a workflow to preview and execute a YAML workflow with your chosen log settings. For the other command options and exit codes, see Command line reference.