From 2d1d4b9ee2a0dd96bb1231b9f544fc5b0b53cba0 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Wed, 4 Sep 2024 22:53:05 -0700 Subject: [PATCH] Introduce "/etc/rsyslog.d/ros2-logging.conf". (#10) Signed-off-by: Tomoya Fujita --- README.md | 16 +++------------- config/ros2-logging.conf | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 config/ros2-logging.conf diff --git a/README.md b/README.md index 85a92d0..20489cc 100644 --- a/README.md +++ b/README.md @@ -111,27 +111,17 @@ So we need to configure `rsyslog` how it manages the log message with `/etc/rsys Examples: ```bash -export RCL_LOGGING_SYSLOG_FACILITY="LOG_LOCAL4" +export RCL_LOGGING_SYSLOG_FACILITY="LOG_LOCAL2" ``` See more details for https://www.rsyslog.com/doc/index.html. #### `rsyslog` -Add the following configuration to `/etc/rsyslog.conf`, replace `` with your own IP address where `fluent-bit` runs. +Copy [ros-logging.conf](./config/ros2-logging.conf) to `/etc/rsyslog.d/`, and replace `` with your own IP address where `fluent-bit` listens on. ```bash -# -# ROS Setting -# - -$template TemplateName1,"%timereported% %hostname% %syslogfacility-text%.%syslogseverity-text%: %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" -$template TemplateName2,"/var/log/ros/%hostname%/%programname%_%procid%_%$now%.log" - -# Log locally with specified templated file name. -local1.* ?TemplateName2;TemplateName1 -# For remote server, it also needs to set those templates -local1.* @@:5140 +sudo cp ./config/ros2-logging.conf /etc/rsyslog.d/ ``` Check the configuration file to see if there is no error, diff --git a/config/ros2-logging.conf b/config/ros2-logging.conf new file mode 100644 index 0000000..7ce64a9 --- /dev/null +++ b/config/ros2-logging.conf @@ -0,0 +1,32 @@ +# +# ROS Setting +# +# This is an example rsyslog configuration for rcl_logging_syslog. +# User needs to update and modify based on the required configuration. +# +# For more information install rsyslog-doc and see +# /usr/share/doc/rsyslog-doc/html/configuration/index.html +# + +# Message Format Template +# See more details for https://www.rsyslog.com/doc/configuration/properties.html +$template TemplateName1,"%timereported% %hostname% %syslogfacility-text%.%syslogseverity-text%: %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" + +# Directory and File Name Template +# See more details for https://www.rsyslog.com/doc/configuration/properties.html +### e.g) /var/log/ros/tomoyafujita/talker_428132_2024-09-04.log +$template TemplateName2,"/var/log/ros/%hostname%/%programname%_%procid%_%$now%.log" +### e.g) /var/log/ros/2024/09/04/tomoyafujita/talker_428151.log +$template TemplateName3,"/var/log/ros/%$year%/%$month%/%$day%/%hostname%/%programname%_%procid%.log" +### e.g) /var/log/ros/2024-09-04/tomoyafujita/info/talker-428214.log +$template TemplateName4,"/var/log/ros/%$now%/%hostname%/%syslogseverity-text%/%programname%-%procid%.log" + +# Log locally with specified templated file name. +local1.* ?TemplateName2;TemplateName1 +local2.* ?TemplateName3;TemplateName1 +local3.* ?TemplateName4;TemplateName1 + +# For remote server, it also needs to set those templates +local1.* @@:5140 +local2.* @@:5140 +local3.* @@:5140