Persistent logging has been significantly improved in version 1.3. You may consider upgrading if you need it.

If you have to diagnose some configuration troubles, it may sometimes be interesting to persist the logs over reboot. This can be done by changing the location of the logs to the internal flash memory.

Logging to the flash memory will decrease the memory's lifespan. You should do this only temporary for diagnose purpose. The lifespan reduction will depend on the amount of logging.

If you change the logging destination to make it persistent, these logs will not be shown through the Manager web interface.

You can do so through the CLI either with the following quick setup or by following the step-by-step guide:

Run this script in the gateway CLI terminal:

sudo sed -i 's/SYSLOGD_OPTS/#SYSLOGD_OPTS/g' /etc/conf.d/busybox-syslogd
sudo sed -ie "\$aSYSLOGD_OPTS=\"-s 200 -b 10 -D -O /var/log-persistent/messages\"" /etc/conf.d/busybox-syslogd
sudo mkdir -p /var/log-persistent
logger "The logging location has been changed to /var/log-persistent/messages"
sudo rc-service busybox-syslogd restart
logger "The logging location has been changed to /var/log-persistent/messages"
cat /var/log-persistent/messages

CODE

You should see the following output in the last line:

<date> <hour> lorix-one-<serial> user.notice admin: The logging location has been changed to /var/log-persistent/messages
CODE

If it's not the case, please use the step-by-step guide on the other tab.

To persist the logs, edit the syslogd configuration /etc/conf.d/busybox-syslogd. Here is the default content of this file:

nano /etc/conf.d/busybox-syslogd

# Rotate at 2MB
# Keep 10 rotated logs
# Drop duplicates
SYSLOGD_OPTS="-s 200 -b 10 -D"
BASH

By default, the logs are stored to /var/log/messages. We can change this by adding the -O (upper case o, not zero) arguments to store them in /var/log-persistent/messages:

nano /etc/conf.d/busybox-syslogd

# Rotate at 2MB
# Keep 10 rotated logs
# Drop duplicates
SYSLOGD_OPTS="-s 200 -b 10 -D -O /var/log-persistent/messages"
BASH

Save the file.

Create the new folder that we just specified:

sudo mkdir /var/log-persistent
BASH

The, restart syslogd:

sudo rc-service busybox-syslogd restart
BASH

Output

busybox-syslogd  | * Caching service dependencies ...                                                                                    [ ok ]
busybox-syslogd  | * Stopping busybox-syslogd ...                                                                                        [ ok ]
busybox-syslogd  | * Starting busybox-syslogd ...                                                                                        [ ok ]
CODE

You can test the new logging location by logging a message manually:

logger "The logging location has been changed to /var/log-persistent/messages"
BASH

And check that the message has been written to the logs with:

cat /var/log-persistent/messages
CODE


Output

Feb 27 10:44:59 lorix-one-xxxxxx user.notice admin: The logging location has been changed to /var/log-persistent/messages
CODE

This configuration is persistent over reboot. To revers the change, remove the -O argument and restart syslog.