Remote Logging in Apache Airflow
S3, GCS, and Azure Blob Explained βοΈπβ
The Story: Logs That Disappearβ
Your DAG ran overnight.
A task failed.
You open the Airflow UIβ¦
βLog file does not exist.β
This happens when:
- Workers restart
- Pods are rescheduled
- Nodes are auto-scaled
Local logs vanish.
Remote logs survive.
Remote logging is not a feature β itβs a requirement for any serious Airflow deployment.
What Is Remote Logging in Airflow?β
Remote logging means storing Airflow task logs in durable external storage instead of local worker disks.
Supported backends:
- Amazon S3
- Google Cloud Storage (GCS)
- Azure Blob Storage
- Elasticsearch (advanced use cases)
π Airflow streams logs to remote storage while the task is running.
Why Remote Logging Is Mandatory in Productionβ
| Problem | Local Logs | Remote Logs |
|---|---|---|
| Worker restarts | β Lost | β Safe |
| Kubernetes pods | β Ephemeral | β Persistent |
| Multi-worker access | β Inconsistent | β Centralized |
| Compliance | β Risky | β Auditable |
| Cost control | β Disk-heavy | β Lifecycle rules |
How Remote Logging Works (Architecture)β
Task Running on Worker
β Log written to local buffer
β Streamed to remote storage
β Metadata saved in DB
β Webserver reads from remote storage
β Log displayed in UI
π Airflow UI does not read logs from workers when remote logging is enabled.
Enabling Remote Logging (Core Configuration)β
Remote logging is configured in airflow.cfg or environment variables.
[logging]
remote_logging = True
remote_log_conn_id = remote_log_storage
remote_base_log_folder = s3://my-airflow-logs
π Each provider uses its own connection type.
Remote Logging with Amazon S3β
Required Setupβ
- S3 bucket
- IAM role or access keys
- Airflow AWS connection
Example Configurationβ
[logging]
remote_logging = True
remote_base_log_folder = s3://airflow-prod-logs
remote_log_conn_id = aws_default
Example Log Path in S3β
s3://airflow-prod-logs/
βββ dag_id=sales_etl/
βββ task_id=transform/
βββ execution_date=2024-01-10/
βββ attempt=1.log
Inputβ
Task prints:
print("Processing completed successfully")
Output (Log File Content)β
[2024-01-10 02:14:32] INFO - Processing completed successfully
Remote Logging with Google Cloud Storage (GCS)β
Required Setupβ
- GCS bucket
- Service account
- Airflow GCP connection
Example Configurationβ
[logging]
remote_logging = True
remote_base_log_folder = gs://airflow-logs-prod
remote_log_conn_id = google_cloud_default
π Ideal for Cloud Composer and GCP-native environments.
Remote Logging with Azure Blob Storageβ
Required Setupβ
- Azure Storage account
- Blob container
- Airflow Azure connection
Example Configurationβ
[logging]
remote_logging = True
remote_base_log_folder = wasb://airflow-logs@storageaccount.blob.core.windows.net
remote_log_conn_id = azure_blob_default
π Often used in Azure Managed Airflow setups.
Security Best Practices for Remote Loggingβ
β
Use IAM roles / Managed identities
β
Avoid hardcoded credentials
β
Encrypt buckets/containers
β
Restrict write/read permissions
β
Mask secrets in logs
π Logs often contain sensitive operational data.
Log Retention with Remote Storageβ
Remote logging works best when combined with lifecycle rules.
Example Retention Strategyβ
| Age | Action |
|---|---|
| 0β30 days | Hot storage |
| 31β90 days | Cold storage |
| >90 days | Delete |
π Managed entirely by the storage provider.
Performance Considerationsβ
- Logs are streamed asynchronously
- Large logs can slow UI rendering
- Excessive logging increases storage costs
π Use INFO level by default.
Common Mistakesβ
β Enabling remote logging without lifecycle rules
β Using local logging in Kubernetes
β Logging secrets or tokens
β Storing massive logs per task
β Misconfigured storage permissions
Input & Output Example (Production Scale)β
Inputβ
- 200 DAGs
- 30 tasks each
- 2 retries
- Remote logging enabled
- Retention: 60 days
Outputβ
| Metric | Value |
|---|---|
| Logs/day | ~12,000 |
| Storage/month | ~150β300 GB |
| Data loss risk | Near zero |
Summary π§ β
- Remote logging is essential for reliability
- S3, GCS, and Azure Blob are all first-class options
- Logs are streamed in near real-time
- Airflow UI reads logs from remote storage
- Lifecycle policies control cost and retention
Key Takeawaysβ
- β Local logs do not scale
- β Remote logging prevents data loss
- β Cloud storage ensures durability
- β Lifecycle rules handle retention cleanly
- β Secure logs like production data
Whatβs Next? πβ
β‘οΈ Airflow File Structure & Best Practices
Understand DAG folders, plugins, logs, configs, and how to structure Airflow like a professional platform