print() and std::cout not showing in ros2 launch: output='screen', emulate_tty, PYTHONUNBUFFERED and pipe buffering, measured
When print() and std::cout lines don't show up in ros2 launch while get_logger().info() lines do, launch is either sending stdout only to launch.log or handing the node a buffered pipe, so add output='screen' and emulate_tty=True to the Node. I ran every case in this post on 2026-11-02 in the official ros:humble-ros-base, ros:jazzy-ros-base and ros:lyrical-ros-base Docker images, starting with the launch below.
$ ros2 launch pk2 v.launch.py
[INFO] [launch]: All log files can be found below /root/.ros/log/2026-11-02-02-20-56-282748-07bdf14633b4-187
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [printer.py-1]: process started with pid [188]
[printer.py-1] [INFO] [1793586056.646174917] [printer]: LOG 0 emit=8349435.536
[printer.py-1] [INFO] [1793586057.047383615] [printer]: LOG 1 emit=8349435.953
...
[INFO] [printer.py-1]: process has finished cleanly [pid 188]
The node called print() five times, once before each of those LOG lines. None of the five PRINT lines reached the terminal. The get_logger().info() lines did. A C++ node with std::cout behaved the same way. There's no error message for this. The output just isn't there, or it shows up seconds late, all at once.
Two separate things hide your prints. First, a launch Node without output= uses output='log', and stdout goes only to launch.log. Second, with output='screen' the node's stdout is a pipe, not a terminal, so Python and C++ buffer it. Lines show up when the buffer fills or when the process exits. The fix that worked for both Python and C++ on Humble, Jazzy and Lyrical:
Node(
package='my_pkg',
executable='my_node',
output='screen', # stdout to the terminal, not only to launch.log
emulate_tty=True, # give the node a pseudo-terminal, so stdout is line-buffered
)
With those two keywords, every print() and std::cout << "...\n" line reached the terminal within 2 ms of being written. For Python only, additional_env={'PYTHONUNBUFFERED': '1'} or print(..., flush=True) worked just as well. If you only need to see messages, use the logger. In every run that didn't set RCUTILS_LOGGING_USE_STDOUT, get_logger().info() lines reached the terminal within 22 ms.

What each launch setup did to print, cout and logger lines
All rows below behaved the same on Humble, Jazzy and Lyrical, except the Python buffer size (see Where Humble, Jazzy and Lyrical differed). "Delay" is the time from the print call to the line appearing in the terminal.
| What you have | What I saw |
|---|---|
No output= (or output='log') |
0 of 5 prints on screen. All 5 in launch.log. Logger lines on screen. |
output='screen', Python print() |
5 of 5 on screen, but all in one batch at exit. Delay 0.40 s to 2.03 s. |
output='screen', C++ std::cout << "...\n" |
Same: one batch at exit, delay 0.50 s to 2.11 s. |
output='screen', C++ std::endl |
Real time, delay 2 ms or less. |
output='screen' plus emulate_tty=True |
Real time for Python and C++, 2 ms or less. |
output='screen' plus PYTHONUNBUFFERED=1 |
Real time, 2 ms or less. |
output='screen', print(..., flush=True) |
Real time, 1 ms or less. |
Node crashes (os.abort()) with output='screen' |
0 of 5 prints ever shown. Logger lines were shown. |
| Node stopped with Ctrl+C (SIGINT) | All prints shown, but only at exit. |
ros2 run in a terminal |
Real time. |
ros2 run ... | tee log.txt (any pipe) |
Buffered, one batch at exit. |
RCUTILS_LOGGING_USE_STDOUT=1 with output='screen' |
Now the logger lines are buffered too, delay up to 2.07 s. |
Test setup: two printer nodes, 22 runs per distro
On 2026-11-02 I used the official ros:humble-ros-base, ros:jazzy-ros-base and ros:lyrical-ros-base images. One ament_cmake package held two nodes. printer.py is an rclpy node that calls print() and then get_logger().info() five times, 0.4 s apart, and exits. cpp_printer does the same with std::cout and RCLCPP_INFO. Each line carries its own CLOCK_MONOTONIC timestamp (emit=).
A launch file started one Node per run, with the output, emulate_tty and additional_env keywords switched on or off. I ran ros2 launch inside script, so launch itself had a pseudo-terminal, like in a normal shell. A stamper then recorded the arrival time of every line. Delay is arrival minus emit. After each run I counted the node's lines in every file under ~/.ros/log. There were 22 runs per distro: 12 Python launch cases, 6 C++ launch cases, and 4 ros2 run cases. I also ran one plain Python pipe test with no ROS involved.
The defaults, read from ExecuteProcess's signature on each distro, were the same everywhere: output = 'log' and emulate_tty = False.
Cause 1: no output= means stdout goes to launch.log only
With no output keyword, the five PRINT lines never reached the terminal. They were all in the launch log file, at ~/.ros/log/<date-time-host-pid>/launch.log. That's the directory launch names in its first line, All log files can be found below .... The C++ node was the same: 0 COUT lines on screen, 5 in launch.log. An explicit output='log' gave the same result.
The logger lines did show up in that run. The ROS loggers write to stderr by default (moving them to stdout changed their behaviour, see below), and with output='log' launch still put them on screen. That's why the logger works and print doesn't, and it's the exact situation in the questions linked at the end.
Where things ended up:
| output= | print / cout on screen | print / cout in launch.log | logger on screen |
|---|---|---|---|
| not set | 0 of 5 | 5 | 5 of 5 |
'log' |
0 of 5 | 5 | 5 of 5 |
'screen' |
5 of 5 (buffered) | 0 | 5 of 5 |
'both' |
5 of 5 (buffered) | 5 | 5 of 5 |
One more file showed up in every run: the rcl logging file, named like python3_188_1793586056581.log or cpp_printer_588_...log. In every five-line run that exited normally it had the 5 logger lines and 0 print lines. Don't look for print output there.
Cause 2: output='screen' gives the node a pipe, and pipes are block-buffered
With output='screen' the prints did appear, but late. On Humble the five PRINT lines all arrived at 2.49 s, right before process has finished cleanly. The first one was written 2.03 s earlier. The logger lines in the same run arrived within 16 ms each. The node had already reported why: ISATTY stdout=False. Launch connects the node's stdout to a pipe, and on a pipe both Python and the C++ runtime collect output in a buffer instead of writing each line.
To find the buffer size, I made each node write 300 lines of 64 bytes, 5 ms apart, with output='screen', and grouped the lines by arrival time:
| Node | Humble | Jazzy | Lyrical |
|---|---|---|---|
Python print() |
batches of 128 lines = 8,192 bytes | 8,192 bytes | one batch, all 19,200 bytes at exit |
C++ std::cout << "\n" |
batches of 64 lines = 4,096 bytes | 4,096 bytes | 4,096 bytes |
So a busy node that prints a lot does show output, in chunks. A node that prints a status line now and then looks silent, because nothing appears until 8 KiB have piled up in Python (128 of my 64-byte lines) or 4 KiB in C++ (64 lines). A "\n" in C++ doesn't flush a pipe. std::endl does: with it, every COUT line arrived within 2 ms.
Lyrical is different because of Python. The plain pipe test (2,500 lines of 64 bytes, 1 ms apart, no ROS) printed io.DEFAULT_BUFFER_SIZE = 131072 on Python 3.14.4 and showed a first batch of 2,048 lines, 131,072 bytes. Python 3.10.12 (Humble) and 3.12.3 (Jazzy) printed 8192 and flushed every 128 lines. On Lyrical a Python node has to print 128 KiB before anything shows up, so in practice you see nothing until it exits.
Crashes lose buffered prints, Ctrl+C doesn't
If the output only appears at exit, the next question is what happens when the node doesn't exit cleanly. I tested two cases with output='screen'.
Crash. The Python node printed five lines and then called os.abort(), which stands in for a segfault in a C extension. Launch reported process has died [pid 485, exit code -6, ...]. None of the five PRINT lines ever appeared, on any distro. The logger lines did, because stderr isn't buffered. With emulate_tty=True the same crash showed all five prints. If you add print calls to find where a node crashes, this is how they mislead you: the last lines before the crash are the ones you lose. The rcl log file from that run had 0 logger lines in it too, although the same lines had reached the terminal.
Ctrl+C. A node that prints from a timer every 0.2 s ran under rclpy.spin(). After 3 s I sent SIGINT to the process group, as a terminal does on Ctrl+C. All 12 prints arrived, in one batch, when the node exited (the first was 2.36 s late on Humble). The C++ version showed all 13 COUT lines the same way. Nothing was lost. The Python node ended with a traceback and exit code 1, with rclpy.executors.ExternalShutdownException as the last line on Humble and Jazzy. That traceback is a shutdown issue, not an output issue. I measured it separately in ROS 2 node shutdown: Ctrl+C, SIGTERM and launch's escalation.
Which fix made prints show up in real time
Every option below was combined with output='screen'. The delay is the worst of the five lines in that run, across the three distros.
| Fix | Python delay | C++ delay | Prints survive a crash | Notes |
|---|---|---|---|---|
| none (pipe) | 2.03 s, all at exit | 2.11 s, all at exit | no | the default behaviour |
emulate_tty=True |
2 ms | 1 ms | yes (Python tested) | works for any language, node sees isatty() true |
additional_env={'PYTHONUNBUFFERED': '1'} |
2 ms | no effect expected (Not tested) | Not tested | Python only |
print(..., flush=True) |
1 ms | n/a | Not tested | only the lines you change |
std::endl instead of "\n" |
n/a | 2 ms | Not tested | only the lines you change |
| use the logger | 18 ms | 3 ms | yes, on screen (Python tested) | adds level, time and node name |
emulate_tty=True is the one to use when you can't or don't want to edit the node. It's a launch keyword, so it also works for third-party nodes. One side effect: the logger lines got ANSI color codes. The raw output had ESC bytes only in the emulate_tty runs, and none in the others. If you pipe the whole launch output into a file, those codes end up in it.
For your own Python nodes, PYTHONUNBUFFERED=1 is the smallest change. It goes in additional_env of the Node. Exporting it in the shell before ros2 launch should reach the nodes too, since they inherit launch's environment, but I only measured the additional_env form.
Another launch-file surprise that looks like a node bug: LaunchConfiguration values are strings, see why '2'+'5' gives 25.
Don't send the logger to stdout to "fix" it
A common tip is RCUTILS_LOGGING_USE_STDOUT=1, so that logger lines go to the same stream as print. With output='screen' and no tty, that made things worse. The logger lines arrived between 0.43 s and 2.07 s late, in one batch at exit, just like the prints. Before, they had been on time. If you set it, add emulate_tty=True too. I didn't test RCUTILS_LOGGING_BUFFERED_STREAM.
ros2 run looks fine because your terminal is a tty
Several of the questions say the prints work with ros2 run but not with ros2 launch. In my run, ros2 run in a terminal gave ISATTY stdout=True, and every print and cout line arrived within 1 ms. Then I piped the same command into another program, the way | tee or | grep does. The node reported ISATTY stdout=False. The Python prints were delayed 0.40 s to 2.03 s and the C++ lines 0.50 s to 2.11 s, again in one batch at exit. So the difference isn't ros2 run versus ros2 launch. It's whether stdout is a terminal. A node started from systemd, from a Docker container without -t or from a CI job has the same problem, for the same reason. I didn't measure those three directly.
Where Humble, Jazzy and Lyrical differed
The launch defaults (output='log', emulate_tty=False), where each stream ended up, and the C++ 4,096-byte batches were the same on Humble, Jazzy and Lyrical. Three things differed:
- Python's default buffer size. It was 8,192 bytes on Humble (Python 3.10.12) and Jazzy (Python 3.12.3), and 131,072 bytes on Lyrical (Python 3.14.4). A Python node that printed 19,200 bytes over 1.5 s showed nothing until exit on Lyrical, and its first lines were 1.55 s late. On Humble and Jazzy the first batch came at 128 lines and the worst delay was 0.65 s. Code that "worked well enough" on Jazzy because it printed a lot can look silent on Lyrical.
- The rclcpp SIGINT message was
signal_handler(SIGINT/SIGTERM)on Humble and Jazzy andsignal_handler(signum=2)on Lyrical. - After SIGINT, the Python traceback ended in
rclpy.executors.ExternalShutdownExceptionon Humble and Jazzy. On Lyrical my filter caught only theTracebackline, so I can't tell you its last line. Exit code 1 on all three.
Not tested
XML and YAML launch files (output="screen", emulate_tty), ExecuteProcess without Node, component containers, python3 -u in a shebang, sys.stdout.reconfigure(line_buffering=True), RCUTILS_LOGGING_BUFFERED_STREAM, PYTHONUNBUFFERED with a C++ node, crashes of a C++ node, SIGTERM and SIGKILL, systemd, docker run without -t, Windows, Cyclone DDS, Foxy, Iron and Rolling.
Measured on 2026-11-02 with ros:humble-ros-base (sha256:d9bcf2e6f72d..., launch 1.0.15, launch_ros 0.19.14, rclpy 3.3.22, rclcpp 16.0.21, ros2cli 0.18.20, rmw 6.1.4, Python 3.10.12), ros:jazzy-ros-base (sha256:8eed0a4669bb..., launch 3.4.12, launch_ros 0.26.13, rclpy 7.1.12, rclcpp 28.1.22, ros2cli 0.32.13, rmw 7.3.4, Python 3.12.3) and ros:lyrical-ros-base (sha256:3224ee150cb0..., launch 3.9.8, launch_ros 0.29.9, rclpy 10.0.11, rclcpp 32.0.3, ros2cli 0.40.9, rmw 7.10.2, Python 3.14.4), default RMW (Fast DDS), on a 2 vCPU Linux host. Full digests are in digests.txt.
Script and raw output: evidence folder. Questions this answers: No stdout logging output in ROS2 using launch, cout behaviour when using ros2 run and ros2 launch, ROS2 launch: No way to get log displayed in console?, Handling Stdin and Stdout in a ROS2 Node Launched via a Launch File, [launch] not wiring python prints to stdout in realtime.
If a print still doesn't show up, check the Node in your launch file for output='screen' and emulate_tty=True first. Then look for the line in launch.log, in the directory launch names in its first line. If launch reported process has died, the buffered prints from before the crash are gone, so rerun with emulate_tty=True to see them.