How to check syslog in Bash on Linux?
By default it's logged into system log at /var/log/syslog
, so it can be read by:
tail -f /var/log/syslog
If the file doesn't exist, check /etc/syslog.conf
to see configuration file for syslogd.
Note that the configuration file could be different, so check the running process if it's using different file:
# ps wuax | grep syslog
root /sbin/syslogd -f /etc/syslog-knoppix.conf
Note: In some distributions (such as Knoppix) all logged messages could be sent into different terminal (e.g. /dev/tty12
), so to access e.g. tty12
try pressing Control+Alt+F12.
You can also use lsof
tool to find out which log file the syslogd
process is using, e.g.
sudo lsof -p $(pgrep syslog) | grep log$
To send the test message to syslogd in shell, you may try:
echo test | logger
For troubleshooting use a trace tool (strace
on Linux, dtruss
on Unix), e.g.:
sudo strace -fp $(cat /var/run/syslogd.pid)
How about less /var/log/syslog
?
A very cool util is journalctl
.
For example, to show syslog to console: journalctl -t <syslog-ident>
, where <syslog-ident>
is identity you gave to function openlog
to initialize syslog.
On Fedora 19, it looks like the answer is /var/log/messages
. Although check /etc/rsyslog.conf
if it has been changed.