Skip to content

How to add SysLogHandler #736

@firesurfer

Description

@firesurfer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions