Skip to content

Commit

Permalink
Introduce "/etc/rsyslog.d/ros2-logging.conf". (#10)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoya Fujita <[email protected]>
  • Loading branch information
fujitatomoya authored Sep 5, 2024
1 parent 0fc7e06 commit 2d1d4b9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<FLUENTBIT_IP>` with your own IP address where `fluent-bit` runs.
Copy [ros-logging.conf](./config/ros2-logging.conf) to `/etc/rsyslog.d/`, and replace `<FLUENTBIT_IP>` 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.* @@<FLUENTBIT_IP>:5140
sudo cp ./config/ros2-logging.conf /etc/rsyslog.d/
```

Check the configuration file to see if there is no error,
Expand Down
32 changes: 32 additions & 0 deletions config/ros2-logging.conf
Original file line number Diff line number Diff line change
@@ -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.* @@<FluentBit IP Address>:5140
local2.* @@<FluentBit IP Address>:5140
local3.* @@<FluentBit IP Address>:5140

0 comments on commit 2d1d4b9

Please sign in to comment.