I'm using an embedded Linux OS which was built using yocto. I'm trying to alter busybox syslogd in order to have it output to both a file & buffer. so I can use logread -f as well as have the output saved onto a file for future in case I need to look at them later. Now the issue I'm seeing is that after I alter the syslogd-startup.conf file to the following:

DESTINATION=" file buffer"       # log destinations (buffer file remote)
LOGFILE=/mnt/userrw/sd/logs   # where to log (file)
REMOTE=loghost:514      # where to log (syslog remote)
REDUCE=no           # reduce-size logging
DROPDUPLICATES=no       # whether to drop duplicate log entries
ROTATESIZE=2000           # rotate log if grown beyond X [kByte]
ROTATEGENS=2           # keep X generations of rotated logs
BUFFERSIZE=2000         # size of circular buffer [kByte]
FOREGROUND=no           # run in foreground (don't use!)
#LOGLEVEL=7         # local log level (between 1 and 8)

and then I run restart command on /etc/init.d/syslog and then run the following command:

ps aux | grep syslogd

I get the following confirming that my args for syslogd is correct:

ps aux | grep syslogd
root      1648  0.3  1.7   4236  2588 ?        S    14:35   0:00 /sbin/syslogd -n -O /mnt/userrw/sd/logs -s 2000 -b 2 -C2000
root      1671  0.0  0.3   2240   496 pts/0    S+   14:35   0:00 grep syslogd

BUT the issue is that It never prints to the file. Only to the buffer. if I take out the-C2000 arg (i.e. have DESTINATION=file only) then it does print to a file. How can I get it to output to BOTH file & buffer? Is this not doable? my syslogd.conf file is empty. Should I be using that to output to file and use the syslogd-startup.conf to output to buffer?

  • Personally I wouldn't try to modify the source. Instead work on a solution to wrap the existing tools. such as busybox syslogd -C2000; busybox logread -f | tinylog -k 2 /path/to/logs. (tinylog and other alternatives are discussed here). – Patrick Jun 11 '18 at 19:51

Looking at some sources for syslogd.c in a version of busybox, it looks like this is not possible. The appropriate code seems to be:

    if (LOG_PRI(pri) < G.logLevel) {
          if ((option_mask32 & OPT_circularlog) && G.shbuf) {
          log_locally(now, G.printbuf, &G.logFile);

So if you log to buffer, it returns without logging to file too. It seems a bit shortsighted. Perhaps you could patch your yocto to remove the return; statement.

  • Just to clarify you also need to take out the ``` //match = 1; ``` line a couple of lines above this if statement. I tested it and it works. Now I have to figure out how to apply it as a patch to my yocto bitbake build – JJ Adams Mar 21 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.