How to Wrap Long Lines in a Task Log in the Apache Airflow® UI
A long line in an Apache Airflow® task log stays on one row: its end is hidden past the right edge of the log, and you have to scroll sideways to read it. The log's Log Settings menu has a Wrap option that continues long lines on the next rows, so every line fits on screen. This guide wraps a long log line on Airflow 3.4.0.
The Example
A Dag called long_log_line has one task, write_long_line, that writes a single long line to the task log: the sentence "This line is long." twenty times.
Prerequisites
- Apache Airflow® running, for example with
airflow standalone, and itsdagsfolder in yourAIRFLOW_HOME.
Step 1: Write a Dag That Logs a Long Line
Create dags/long_log_line.py:
import logging
from airflow.sdk import dag, task
log = logging.getLogger(__name__)
@dag(schedule=None, tags=["demo"])
def long_log_line():
@task
def write_long_line():
log.info("This line is long. " * 20)
write_long_line()
long_log_line()

logis a logger from Python'sloggingmodule, andlog.info(...)writes a line to the task log at theINFOlevel."This line is long. " * 20repeats the sentence 20 times, so the task logs one line of 380 characters.
Step 2: Open the Task's Log
Trigger the Dag and open the write_long_line task's log (How to Read a Task Log in the Apache Airflow® UI shows where to click):

Line 4 stays on one row and is cut off at the right edge, in the middle of a word. The rest of it is still there: the log scrolls sideways, and in my check its content was 3,007 pixels wide in a box 1,136 pixels wide. When you scroll, the whole log moves, so the start of every line goes out of view.
Step 3: Turn On Wrap
Above the log on the right, click Log Settings, the gear icon:

Click Wrap. The letter next to each item is its keyboard shortcut: pressing w while the log is open turns wrapping on or off without the menu.

Line 4 now continues on the next two rows, which start under its timestamp, and all twenty sentences are visible. It's still one log line: the number 4 appears once, and the next line is 5.
Step 4: Turn It Off Again
With wrapping on, the menu's first item reads Unwrap. Click it, or press w again, and long lines go back to one row each.
Airflow remembers the choice in your browser. After a page reload the log stayed wrapped, and so did the logs of other Dags I opened later, until I turned wrapping off.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Scrolling sideways to read a long line | The whole log moves, so the start of every line goes out of view | Turn on Wrap |
| Pressing w while the cursor is in the Search logs box | The letter goes into the search box, and wrapping doesn't change | Click outside the box first, then press w |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Every log you open is wrapped | Wrapping was turned on earlier in the same browser, and Airflow kept the choice, or the [api] default_wrap setting is True | Click Unwrap in Log Settings, or press w |
| Pressing w does nothing | The cursor is in a text box, such as Search logs | Click outside the box, then press w |
FAQ
Does Wrap change the log itself?
No. The choice is saved in your browser, not in Airflow, and it changes only how the page shows the log.
Can logs open wrapped without clicking Wrap first?
Yes, in a browser that hasn't saved a choice yet. Airflow's [api] default_wrap setting is, in the configuration reference, the "Default setting for wrap toggle on DAG code and TI log views", and it's False unless you change it. I stopped Airflow and started it again with the setting turned on through its environment variable (How to Change the Port and Host of the Apache Airflow® API Server explains how these variables are named):
export AIRFLOW__API__DEFAULT_WRAP=True
airflow standalone
In a browser with no saved choice, the log of write_long_line opened wrapped. A saved choice still wins: after I pressed w and reloaded the page, the log stayed unwrapped.
Conclusion
write_long_line logged a line too long for the log, and it ran past the right edge. Wrap in the Log Settings menu, or the w key, continued it on the next rows, and Unwrap put it back on one row. Airflow remembers the choice in your browser, so one click keeps long lines readable in every log you open.
Additional Resources
- UI overview: Logs — the Logs tab and the other task instance tabs.
Apache®, Apache Airflow and Airflow® are either registered trademarks or trademarks of The Apache Software Foundation in the United States and/or other countries. No endorsement by The Apache Software Foundation is implied by the use of these marks.
