Skip to content

How to View cloudSwXtch and swXtchBridge Logs using shell

Last validated:
View as Markdown

WHAT TO EXPECT

In this article, users will learn how to view logs in both cloudSwXtch and swXtchBridge VMs using shell commands.

Getting logs from a container can be done in several ways. In the next examples, you can use either swx-bridge or swx-swxtch depending on the desired log. But the commands will be the same. For example, to get the bridge logs, the commands can be:

  1. docker logs swx-bridge
  2. sudo journalctl -t swx-bridge
  3. journalctl CONTAINER_NAME=swx-bridge

Even if the commands will read the same logs, they are not the same because they are different ways of accessing the log. There are also differences in the output. For example, by default, the first command using docker won’t print a timestamp:

info: launcher.go:39: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 Bootstrap.cpp[34]: swx-tunnel App: packet proxy tunnel interface 'swx0-tun' (index: 6).
swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 ControlServer.cpp[51]: Starting swx-tunnel App's Control (RPC) Server...
info: launcher.go:39: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 RpcServer.cpp[102]: Rpc server listening on 127.0.0.1:10004
swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 PktProxy.cpp[293]: Starting swx-tunnel App's Packet Proxy...
swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[151]: Cgroup directory already exists: "/sys/fs/cgroup/swx-protocol"
info: launcher.go:39: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[170]: Moved PID 64 into "/sys/fs/cgroup/swx-protocol/cgroup.procs"
info: launcher.go:39: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[187]: There are not isolated cpus, defaulting to all available CPUs
swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[216]: Applied cpuset.mems=0 to "/sys/fs/cgroup/swx-protocol"
swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[252]: Restricted to CPUs 0-3 in "/sys/fs/cgroup/swx-protocol"
swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[274]: Applied CPU limit of 80% per CPU (4 CPUs, quota=320000 100000) to "/sys/fs/cgroup/swx-protocol"
info: launcher.go:39: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[337]: Final cgroup content for "/sys/fs/cgroup/swx-protocol": procs=2 entries, threads=18 entries, cpuset.mems=0, cpuset.cpus=0-3
swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 PktProxy.cpp[110]: Packet's dest. IP 156.104.12.255 doesn't map to a known MAC address. Ignoring packet.
info: launcher.go:45: Could not set default mac for protocol swx-tunnel. Retrying...
info: launcher.go:39: swx-tunnel: Dec 04 15:26:00 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 ControlServer.cpp[24]: Handling Set Default Mac Message
info: launcher.go:69: Default mac has been set for protocol swx-tunnel

The same log using journalctl will give:

Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: info: launcher.go:39: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[170]: Moved PID 64 into "/sys/fs/cgroup/swx-protocol/cgroup.procs"
Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: info: launcher.go:39: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[187]: There are not isolated cpus, defaulting to all available CPUs
Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[216]: Applied cpuset.mems=0 to "/sys/fs/cgroup/swx-protocol"
Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[252]: Restricted to CPUs 0-3 in "/sys/fs/cgroup/swx-protocol"
Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[274]: Applied CPU limit of 80% per CPU (4 CPUs, quota=320000 100000) to "/sys/fs/cgroup/swx-protocol"
Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: info: launcher.go:39: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 thread.cpp[337]: Final cgroup content for "/sys/fs/cgroup/swx-protocol": procs=2 entries, threads=18 entries, cpuset.mems=0, cpuset.cpus=0-3
Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: swx-tunnel: Dec 04 15:25:59 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 PktProxy.cpp[110]: Packet's dest. IP 156.104.12.255 doesn't map to a known MAC address. Ignoring packet.
Dec 04 15:26:00 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: info: launcher.go:45: Could not set default mac for protocol swx-tunnel. Retrying...
Dec 04 15:26:00 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: info: launcher.go:39: swx-tunnel: Dec 04 15:26:00 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal #64 ControlServer.cpp[24]: Handling Set Default Mac Message
Dec 04 15:26:00 fs-c42-br01.us-central1-f.c.swxtch-sa-project.internal swx-bridge[1302]: info: launcher.go:69: Default mac has been set for protocol swx-tunnel

It is recommended for users to send logs from both services to support@swxtch.io. The logs should cover 24 hours’ worth of time, starting from before the issue to the present.

PLEASE NOTE

It is recommended to read journalctl documentation from its man page.

PLEASE NOTE

To find the logs, use the following file paths:

  • cloudSwXtch: /var/log/swx/swxtch
  • swXtchBridge: /var/log/swx/bridge
  • Host changes (NIC drivers, hugepages, boot configuration): /var/log/swx/hostd, root only

The containers' logs and syslog

The swx containers (swx-swxtch, swx-omni, swx-bridge) log to journald, which already stores, rotates and caps them. rsyslog would copy every line into /var/log/syslog (or /var/log/messages) too: the containers are verbose, so the syslog file would hold everything twice and could fill the disk. The installers therefore add /etc/rsyslog.d/30-swx.conf, which stops these messages in rsyslog. Older versions wrote the same filter lines into /etc/rsyslog.conf; the 5.0 installers move them to that file.

rsyslog reads the files of /etc/rsyslog.d/ in name order, and a message the drop-in stops never reaches a rule read after it. To forward the swx logs to a syslog server or a SIEM, choose one of:

  • A collector that reads the journal (for example systemd-journal-upload, the Fluent Bit systemd input, the Vector journald source, or the journald input of the Splunk, Elastic or Datadog agents). It is not affected by the rsyslog filter. Select the swx logs by SYSLOG_IDENTIFIER or CONTAINER_NAME (swx-swxtch, swx-omni, swx-bridge).
  • An rsyslog forwarding rule in a file that sorts before 30-swx.conf (for example, /etc/rsyslog.d/20-forward-swx.conf), so that it sees the messages before they are stopped. Restart rsyslog afterwards.
  • --syslog_passthrough, when the forwarding rule must stay where it is (a file such as 60-siem.conf or 99-remote.conf, or the rules section of /etc/rsyslog.conf after its include, as on RHEL-family hosts). The installer then leaves that component's messages to rsyslog: they reach every forwarder, and they also land in /var/log/syslog (or /var/log/messages), so rotate that file by size. The flag applies per installer run to the components it installs (swx-install.sh passes it to the swXtch and OMNI, swx-bridge-install.sh to the bridge); --persist reinstalls keep it, and --syslog_passthrough false turns it off again. 30-swx.conf names a component installed this way in a # --syslog_passthrough: <container> comment.

When the filter is installed, the installer warns about every file it finds that rsyslog reads after 30-swx.conf and that forwards messages off the host (@host, @@host, or an omfwd, omrelp, omgssapi, omkafka, omhttp or omelasticsearch action), naming the file and --syslog_passthrough.

/var/log/swx is owned by root and writable only by root (mode 0755). Its omni folder belongs to the unprivileged OMNI container user (UID 10443).

PLEASE NOTE

Using wXcked Eye, users can get the logs and even more useful information that will help troubleshooting and analyzing. Please, read the Support page in wXcked Eye.

Below are several useful arguments that can filter the logs. Users can use any combination of them to create the desired output. These arguments can be used on any of the commands given above, except for the English words for time references that can’t be used with the docker command. But the examples will use only the sudo journalctl command.

Following Logs (-f)

The -f argument will (F)ollow the logs and continually update. Logs prior to the call will not display.

sudo journalctl -t swx-swxtch -f

NOTE

The .service is not necessary and will work with or without.

Listing a Certain Number of Lines in a Log (-n)

The -n argument can be used to list a specific (N)umber of lines in a log, starting from the earliest, and with the ability to scroll down if the number of lines is greater than what the console can show using cursor keys:

sudo journalctl -t swx-swxtch -n <number of lines>

Displaying Logs within a Timeframe (--since --until)

The --since and --until commands will display logs within a set timeframe (between 2 dates or time references):

sudo journalctl -t swx-swxtch --since <Time-Reference-1> --until <Time-Reference-2>

Where can be a date or a keyword:

  • YYYY-MM-DD HH:MM:SS (can be used with date only or time only)
  • yesterday (Midnight (00:00) of the previous day)
  • today (Midnight (00:00) of the current day)
  • now (The current moment)
  • ago (Relative times using the word ago, like "1 hour ago", "2 days ago", "30 minutes ago")

Example 1:

sudo journalctl -t swx-swxtch --since 2025-10-07 --until 2025-10-08

Example 2:

sudo journalctl -t swx-swxtch --since "yesterday" --until "1 hour ago"

Displaying Logs since Last Boot (-b)

The -b argument will display logs since the last (B)oot:

sudo journalctl -t swx-swxtch -b

List boots (--list-boot)

The --list-boot argument can be used to list all the boots in date/time order:

sudo journalctl -t swx-swxtch --list-boot

Change Logs to UTC (--utc)

The --utc argument switches logs from local time to UTC:

sudo journalctl --utc

Exporting Logs (>)

Users can use the shell output redirector (character >) to send the output of any command to a file, putting the filename right after the character. The following command will export the log to a .log file.

sudo journalctl -t swx-swxtch > <file-name.log>

Example

sudo journalctl -t swx-swxtch > cloudswxtch-service.log

Arguments can also be combined to export logs from a timeframe or from the last boot. It is recommended that logs should cover at least 24 hours’ worth of time, starting from before the issue until the present.

Example:

LAST BOOT:
sudo journalctl -t swx-swxtch -b > cloudswxtch-service.log

TIMEFRAME:
sudo journalctl -t swx-swxtch --since 2 days ago --until 1 hour ago > cloudswxtch-service.log