Add per node & component log level support
Maintainers usually reply within 1 day
@penww is already working on this.
Since Apr 2, 2026.
Assessment
This issue has not been assessed yet.
Description
Description
This issue tracks the addition of a log_level field to NodeOptions, allowing users to set the initial log severity for a node at construction time. This enables per-component log level customization, particularly useful in component container deployments.
Motivation
In ROS 2, all nodes loaded into a component container share the same process. Prior to this change, there was no way to specify a different initial log level for individual components at load time — the only option was to set a global log level or call set_level() programmatically after construction.
This is a common need in production deployments where:
- Different components have different verbosity requirements (e.g., a sensor driver at
WARN, a planner atDEBUG). - Operators want to configure log levels declaratively via launch files or
LoadNodeservice calls without modifying node source code. - Debugging a single component in a multi-component container should not require restarting the entire process with a global log level change.
We can see this feature has designed but not full implementation:
- LoadNode.srv defined
log_levelfield: https://github.com/ros2/rcl_interfaces/blob/79a773f9fb02dee0de23fb1b08ca4d187b313849/composition_interfaces/srv/LoadNode.srv#L17 - ros2component implement
log_levelargs but not parse: https://github.com/ros2/ros2cli/blob/401876461924b6bd4d4f9db95e22deb6243fce8b/ros2component/ros2component/api/__init__.py#L343 - component_manager not handle
log_levelin the LoadNode request: https://github.com/ros2/rclcpp/blob/f145c9ee04fbaa34f70b6f5cbbe095a6342f97c9/rclcpp_components/src/component_manager.cpp#L150
Expected Behavior:
- Set component log_level with CLI:
ros2 component load /ComponentManager <PKG> <PLUGIN> --log-level debug
- Set component log_level with launch:
def generate_launch_description():
return LaunchDescription([ComposableNodeContainer(
name='component_demo_container',
namespace='',
package='rclcpp_components',
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='<PKG>',
plugin='<PLUGIN>',
log_level='DEBUG', # component log level
),
],
arguments=['--ros-args', '--log-level', 'DEBUG'], # container log level
)])
Design / Implementation Considerations
NodeOptions API
A new log_level getter/setter pair is added to NodeOptions:
// Get the log level (RCUTILS_LOG_SEVERITY_* value; 0 = unset/default)
int log_level() const;
// Set the initial log level for this node
NodeOptions & log_level(int log_level);
The default value is RCUTILS_LOG_SEVERITY_UNSET (0), which preserves existing behavior — no level is applied at construction.
Node construction (node.cpp)
After the node is fully constructed, if log_level is not UNSET, the logger level is applied:
if (options.log_level() != RCUTILS_LOG_SEVERITY_UNSET) {
node_logging_->get_logger().set_level(
static_cast<rclcpp::Logger::Level>(options.log_level()));
}
This is intentionally applied after construction so the logger is fully initialized.
ComponentManager integration (component_manager.cpp)
When handling a LoadNode service request, the log_level field from the request is validated and forwarded to NodeOptions:
if (request->log_level != 0) {
// Validate against known RCUTILS severity values
options.log_level(request->log_level);
}
Invalid values (not one of DEBUG, INFO, WARN, ERROR, FATAL) throw a ComponentManagerException with a descriptive message.
Additional Information
No response
- Dominant language
- C++
- Stars
- 829
- Forks
- 587
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 30
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ros2/rclcpp
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Memory grows per callback group created and destroyed on long lived nodesPossibly taken @jwallace42 claimed this 1 day ago. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 28/100
ros2/rclcpp#3428 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
removing and immediately re-adding a node to the EventsCBGExecutor leaves its entities unregisteredPossibly taken @skyegalaxy claimed this 10 days ago. Openbug
ros2/rclcpp#3418 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Humble] Removing a node with more than one auto-added callback group leaves a dangling guard condition in the executorPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
ros2/rclcpp#3410 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
EchoTools/nevr-runtime#2912 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug-unconfirmed
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
libc++
Difficulty 1/5 Under an hour Newbie friendliness 88/100
llvm/llvm-project#246508 ·
Maintainers usually reply within 1 day