Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add SysLogHandler #736

Open
firesurfer opened this issue Oct 10, 2023 · 0 comments
Open

How to add SysLogHandler #736

firesurfer opened this issue Oct 10, 2023 · 0 comments

Comments

@firesurfer
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant