OpenWrt Forum Archive

Topic: HowTo redirect logs from different daemon/components to separate files

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

Hi there,

I want to know how the logs can be redirected to a component/daemon specific file. i.e. i want to have separate log file for every process.

Currently logs are written in a socket /dev/log. is there any mechanism in logd to redirect logs to separate file as per process ?

For example for dnsmasq i want a file in /tmp/dnsmasq.log with the dnsmasq specific logs.

Basic informations:
openwrt version : 15.05 ( git.openwrt.org/15.05/openwrt.git )

/sbin/ubusd and /sbin/logd are running for logging purpose.


Thanks
Amitesh Kumar

Not per process.

You may utilise syslogd to forward the messages to a remote syslog server and attempt to segregate there.

Max, you don't need a remote syslog server to do that.

Use something like syslog-ng or syslog-ng3, which come with some extensive filter technics. Depending on the log source and the log entry you might archive something like "per process" logging.

But why so complicated? Most daemons have an option to set the log destination. Wouldn't that be easier?

@MagicSimon - one should not presume the presence of external storage, eh? And the BusyBox implementation of syslogd includes a file-based logging option.

Max Hopper wrote:

one should not presume the presence of external storage, eh?

One should not presume anything. For example that the resulting logfiles won't comfortably fit in memory.

(Last edited by metai on 27 Jun 2016, 21:07)

metai wrote:

For example that the resulting logfiles won't comfortably fit in memory.

Here you equate persistent storage, the JFFS2 in the MTD, with 'memory'?

Max Hopper wrote:
metai wrote:

For example that the resulting logfiles won't comfortably fit in memory.

Here you equate persistent storage, the JFFS2 in the MTD, with 'memory'?

Persistent or volatile.

Let's get real: The default logfile buffer is 32k. Keeping even a considerably larger version on-device will strain neither on flash nor RAM. (And before you get started, no, flash memory wear is not a significant factor.)

(Last edited by metai on 27 Jun 2016, 23:53)

The discussion might have continued from here.