Setting up logging
syslogd is started on startup. You can read it with 'logread'
Syslog logging can be very useful when trying to find out why things don't work.
There are two options for where to send the logging output:
(1) to a local file stored in RAM,
(2) to a remote system.
The local file option is very easy but because it is stored in RAM it will go
away whenever the router reboots. Using a remote system allows the output to
be saved for ever.
The existing rcS file in whiterussian rc3 (and newer) reads the nvram variable
"log_ipaddr", so remote logging gets activated by simply doing:
nvram set log_ipaddr=
nvram commit
To run syslogd and klogd you should edit /etc/inittab and add the following
two lines:
::respawn:/sbin/syslogd -n
::respawn:/sbin/klogd -n
This tells syslogd to write the log file to /var/log/messages. However, note
that /var is linked to /tmp but we may need to create /var/log at boot time if
it is not already automatically created. Do that by adding the following to
/etc/init.d/rcS:
mkdir /var/log
If you want to log to a remote system, add -R to the syslogd line
in /etc/inittab. In this case you don't need to add the mkdir /var/log command
to the startup:
::respawn:/sbin/syslogd -n -R debian
::respawn:/sbin/klogd -n
If you want both local and remote logging, add -L -R to the syslogd
line in /etc/inittab. Use the following line in /etc/inittab:
::respawn:/sbin/syslogd -n -L -R debian
However, you will need to tell the remote system to listen for
the log messages. On Red Hat Linux system that requires adding the -r flag to
the syslogd startup (which is done by editing /etc/sysconfig/syslog). Also,
on Red Hat Linux system the log messages received from the remote system appear
in /var/log/messages interspersed with the local messages. You may need to
check the man page for your host syslogd program.
Expect the log messages to arrive through UDP port 514.
Review / Command Summary
nvram set log_ipaddr=<192.168.4.251>
nvram commit
/etc/initab
::respawn:/sbin/syslogd -n
::respawn:/sbin/klogd -n
/etc/init.d/rcS
mkdir /var/log
To handle the logging on the remote side of the connection, add the -r option
to the command line that starts syslogd and you're good to go. If you're using
Ubuntu, for example, edit /etc/init.d/sysklogd and change the line that reads:
SYSLOGD="-u syslog"
To read:
SYSLOGD="-r -u syslog"
Of course, if you're like me and think that syslogd is so last generation, you
can install syslog-ng instead, which accepts remote logging by default.
On Debian /etc/init.d/sysklogd:
SYSLOGD="-r"
--------------------------------------------------------------------------------