OpenWrt Forum Archive

Topic: Produce system log file on a daily basis

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi all.

I recently installed OpenWRT on my Asus RT-N56U router, and so far I'm pretty happy with it.

Some of my devices seem to loose connection with it from time to time, and although I believe it's the devices themselves or the Zyxel wifi extender that the real issue, I'd like to gather some OpenWRT logs in case I find something that may explain the connectivity loss.

First I though I'd dump logread output to a file once a day, but logread doesn't seem to store log files for more than a short time. Kind of behaves like a ring buffer of some kind.

Suggestions on how to produce log files (preferably without duplicates) say once a day will be appreciated.

Greetings,
kenneho

Just implement "remote logging" to another machine. Not to lose anything.

augustus_meyer wrote:

Just implement "remote logging" to another machine. Not to lose anything.

Thansk for the reply.

It's a very good idea, but unfortunately I don't have any servers in my network, all my devices powered off most of the time, so my aim is to store to log on the OpenWRT router itself.

If you just want to keep the logfile it in memory, the simplest way would be to increase OpenWrt's log buffer, by a lot. The default is 16 kB, you can safely increase this to a much larger size. You can do this in LuCI, under System > "Logging" Tab, then reboot, or edit /etc/config/system.

And of course, you can set a cronjob to save the output of logread to files in the /tmp ramdrive, permanently store them in flash or on an external USB drive, even mail them out on a regular basis. There are lots of possibilities, but they require some acumen with shell scripting and the command line.

(Last edited by metai on 5 Jun 2016, 04:06)

I think I'll simply insert a small USB pen drive, and have a command like this execute at startup:

logread -f 2>&1 > /path/to/usb/drive/myfile.log

For what is't worth, this is the command I've put in /etc/rc.local:

/sbin/logread -f >/mnt/usb/logread.txt-`date +"%F-%H_%M"` &

I guess you simply putting

logread -f >> mnt/usb/logread.txt/.txt &

would work.

The ">" redirects the standard output, replacing the current log

The ">>" redirects the standard output, adding new lines to the current log

The discussion might have continued from here.