[SOLVED] Persistent Logging

On 18.06.1, r7258-5eb055306f, I realized my router rebooted mysteriously. It was not a power issue as it is connected to a UPS (as are other devices that didn't reboot/shutdown)

A) is it possible to fund out the reason for the last reboot?

B) is it possible to read logs from before the last reboot with the standard OpenWRT config? I can only find logs for the most recent boot sequence

C) If B is a no, how do I setup logs to be stored locally (I will figure out how to store them on a USB drive, if need be, separately)

TIA

Easiest for a "quick check" is to open an ssh connection and "tail" the log into a console. Of course, as soon as you get any of this rigged up, it will run perfectly for months :wink:

The logs are not persisted by default as /tmp/ /var/ is a RAM-based file system. Continuous writes to flash shorten its life very quickly.You can add a USB "stick" pretty easily. As I recall, the block-mount package, plus the appropriate USB drivers are required. If you've got a Linux-based box, you can format the drive there. FAT is a possibility too, but doesn't support things like permissions and owners.

has a link to the instructions, as well as answering a couple common questions around mounting file systems.

I believe the "stock" logger can log to a file with appropriate configuration. I personally use syslog-ng and logrotate. syslog-ng can enable remote logging over TLS.

1 Like

it depends on the reason for the reboot. If it's a graceful reboot (initiated by
a command), then it may be possible to save (or log remotely via rsyslog or
syslog-ng) the reason for the reboot.

But if the reboot is due to something going wrong, you may not have a chance to
do anything, and if the system is rebooting because it became corrupt, you
really don't want it writing anything to storage locally (who knows what will
happen, the system is corrupt after all)

so enable rsyslog or syslog-ng and have them log to a remote system (probably
via UDP so that there's less state that could block the logs) and keep your
fingers crossed

David Lang

1 Like

logging to /mnt/sda1/logs (an USB drive)

I used this guide to setup the drive. will see if the mount persists after a reboot.

https://openwrt.org/docs/guide-user/storage/usb-drives-quickstart

thanks

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.