ros2 / ros2/launch

How to add SysLogHandler

Open
#736 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
155
Forks
182
Avg merge
2d 14h
Merged PRs (30d)
6

Description

Hi,
I would like to write all log messages which are written to launch.log per default additionally to the system log (and later on to a remote logging server).

What I tried so far is to add a SysLogHandler in my launch.py file to every registered logger:

import launch.logging
import logging.handlers
import logging

def generate_launch_description():

    for logger in launch.logging.LaunchLogger.all_loggers:
        handler = logging.handlers.SysLogHandler(address = '/dev/log')
        logger.addHandler(handler)
        logger.critical("test")

The "test" message is logged correctly but the actual output of all other loggers is not shown in the syslog. I guess the reason for this that the loggers are created when the LaunchDescription is executed.

So my question is: How can a add an additional handler to every logger created by ros2 launch in order to write all log messages which are written to launch.log also to the syslog.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how launch.logging.LaunchLogger instances are created and how launch.py's generate_launch_description() relates to that lifecycle. Review the logger and handler entry points mentioned in the issue, including LaunchLogger.all_loggers and SysLogHandler. Done means a supported approach exists for sending all messages written to launch.log to syslog.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.