OpenWrt Forum Archive

Topic: Chaos Calmer and logging

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

Just moving from Attitude Adjustment to Chaos Calmer and noticed a move from syslogd to logd.  I can't find alot of documentation so hope I am not asking redundant questions:
1. I see many posts about limitations in logd buffer size.  syslogd looks to be the better tool. why the change?   
2.  How do I log to file with logd?
3. I built an image using busybox logread and logd logread failed to work, said it could not find a buffer?  Looks like busybox logread is not compatible with logd?
4.  is there a way in the make menuconfig to select using syslogd instead of logd?
5.  I started syslogd logging to a file with logd running and saw that syslogd "took over" the log data.  logread still worked but only showed log data up until syslogd was started after which log data went through syslogd to the file I specified.  Can I kill logd and simply run syslogd?
6.  How would I do remote logging with logd?

Good logging is critical and seems like we took a step backwards in switching from syslogd to logd.

I answered some of my questions.  Looks like the non busybox version of logread is able to log remotely and to a file, see below.  I was used to seeing these as options to syslogd so ran logd --help and saw no options.

Only thing I am missing now is syslogd's ability to rotate log files and the ability to specify the number of log files?

Usage: logread [options]
Options:
    -s <path>           Path to ubus socket
    -l  <count>         Got only the last 'count' messages
    -e  <pattern>       Filter messages with a regexp
    -r  <server> <port> Stream message to a server
    -F  <file>          Log file
    -S  <bytes>         Log size
    -p  <file>          PID file
    -h  <hostname>      Add hostname to the message
    -P  <prefix>        Prefix custom text to streamed messages
    -f                  Follow log messages
    -u                  Use UDP as the protocol
    -0                  Use \0 instead of \n as trailer when using TCP

logd itself is really small and does not offer any other options than the size of its own internal buffer (default only 16 kB). I have increased the buffer size in my own build to 64 kB.

Sources for both logd and logread (part of "ubox") can be found here:
http://git.openwrt.org/?p=project/ubox. … og;hb=HEAD

You might try the "follow log messages" (= tail) option -f in logread, i.e. "logread -f" and pipe that into the file you want to have as the storage. But there is no naming/rotation etc. logic.

man logrotate

try it and see revealed that logread when logging to file defaults to rotating the current syslog to syslog.old, so has built in rotation to 2 files.

Still I could not make it happen... My motto is to preserve the logs if my system got crashed. Please suggest me how can I do this..?

Make sure that you copy the log files to permanent flash instead of using ramdisk like /tmp and /var

Openwrt tries to avoid writing unnecessarily to flash (in order to avoid flash wear), so all logs etc. are usually only in RAM. If you use logrotate or something similar, make sure that it copies the files to actual flash/HDD/whatever.

(Last edited by hnyman on 7 Nov 2016, 12:23)

Hi Hnyman,

I can do that, But I don't know how to use logrotate or some other daemons to save the logs in HDD.

Could please provide me the details how can I use logrotate or some other daemons to save the logs in HDD.?

Thanks,
Ramesh

Make a filesystem on a USB flash drive, mount it somewhere and log to this filesystem. A cursory search of this forum will show this question has been asked and answered many times just in the last few weeks

So, is there a way to do remote syslog logging with Chaos Calmer?

The discussion might have continued from here.