System Logs

The system log or syslog feature allows users to collect and view logs from the router. These logs are critical to ensure effective monitoring, debugging and diagnostic capabilities This feature is implemented using rsyslogd, a standard Linux utility for collecting and forwarding syslog messages.

Viewing and monitoring Syslogs on SONiC

By default, SONiC collects syslogs in the /var/log/ directory. root users can access files in this directory to view syslogs.

admin@sonic:~$ sudo head /var/log/syslog
Sep 24 18:20:05.539642 sonic INFO systemd[1]: logrotate.service: Succeeded.
Sep 24 18:20:05.540347 sonic INFO systemd[1]: Finished Rotate log files.
Sep 24 18:20:15.296046 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray0.fan0: set pwm to 28
Sep 24 18:20:15.296124 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray0.fan1: set pwm to 28
Sep 24 18:20:15.296137 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray1.fan0: set pwm to 28
Sep 24 18:20:15.296156 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray1.fan1: set pwm to 28
Sep 24 18:20:15.296241 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray2.fan0: set pwm to 28
Sep 24 18:20:15.296241 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray2.fan1: set pwm to 28
admin@sonic:~$ 

To follow syslog messages:

admin@sonic:~$ sudo tail -f /var/log/syslog
Sep 25 04:22:28.939921 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray1.fan0: set pwm to 26
Sep 25 04:22:28.939994 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray1.fan1: set pwm to 26
Sep 25 04:22:28.939994 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray2.fan0: set pwm to 26
Sep 25 04:22:28.940062 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray2.fan1: set pwm to 26
Sep 25 04:22:28.940138 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray3.fan0: set pwm to 26
Sep 25 04:22:28.940214 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray3.fan1: set pwm to 26
Sep 25 04:22:28.940296 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray4.fan0: set pwm to 26
Sep 25 04:22:28.940378 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray4.fan1: set pwm to 26
Sep 25 04:22:28.940472 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray5.fan0: set pwm to 26
Sep 25 04:22:28.940472 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray5.fan1: set pwm to 26

Alternatively, users can view logs using the show logging SONiC CLI command:

admin@sonic:~$ show logging 
Sep 24 18:20:05.539642 sonic INFO systemd[1]: logrotate.service: Succeeded.
Sep 24 18:20:05.540347 sonic INFO systemd[1]: Finished Rotate log files.
Sep 24 18:20:15.296046 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray0.fan0: set pwm to 28
Sep 24 18:20:15.296124 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray0.fan1: set pwm to 28
Sep 24 18:20:15.296137 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray1.fan0: set pwm to 28
Sep 24 18:20:15.296156 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray1.fan1: set pwm to 28
Sep 24 18:20:15.296241 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray2.fan0: set pwm to 28
Sep 24 18:20:15.296241 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray2.fan1: set pwm to 28

To follow syslog messages using SONiC CLI:

admin@sonic:~$ show logging --follow
Sep 25 04:24:43.099487 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray1.fan1: pwm 27 (delta 1)
Sep 25 04:24:43.139453 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray2.fan0: pwm 27 (delta 1)
Sep 25 04:24:43.159477 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray2.fan1: pwm 27 (delta 1)
Sep 25 04:24:43.199487 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray3.fan0: pwm 27 (delta 1)
Sep 25 04:24:43.219458 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray3.fan1: pwm 27 (delta 1)
Sep 25 04:24:43.259500 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray4.fan0: pwm 27 (delta 1)
Sep 25 04:24:43.279473 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray4.fan1: pwm 27 (delta 1)
Sep 25 04:24:43.319470 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray5.fan0: pwm 27 (delta 1)
Sep 25 04:24:43.339448 sonic INFO pmon#supervisord: thermalctld INFO:cisco.pacific.thermal.cooling_device:fantray5.fan1: pwm 27 (delta 1)

Syslog configuration on SONiC

To add a remote syslog server:

admin@sonic:~$ sudo config syslog add 192.168.0.1
Running command: systemctl reset-failed rsyslog-config rsyslog
Running command: systemctl restart rsyslog-config

While adding a remote syslog server, you can pass optional arguments such as:

admin@sonic:~$ sudo config syslog add -h
Usage: config syslog add [OPTIONS] SERVER_IP_ADDRESS

  Add object to SYSLOG_SERVER table

Options:
  -s, --source TEXT         Configures syslog source IP address
  -p, --port INTEGER RANGE  Configures syslog server UDP port
  -r, --vrf TEXT            Configures syslog VRF device
  -?, -h, --help            Show this message and exit.

For example:

admin@sonic:~$ sudo config syslog add --source 1.1.1.1 --port 6514 --vrf Vrf-blue 192.1.2.1
Running command: systemctl reset-failed rsyslog-config rsyslog
Running command: systemctl restart rsyslog-config

To view the currently configured syslog servers:

admin@sonic:~$ show syslog
SERVER IP    SOURCE IP    PORT    VRF
-----------  -----------  ------  --------
192.1.2.1    1.1.1.1      6514    Vrf-blue
192.168.0.1  N/A          N/A     N/A