2

On my development computer I compiled a kernel module that I want to use on an Ubuntu system. It's a simple test module for now that just printk's a message.

On my development computer I can test that this works by cat /var/log/messages

On my Ubuntu computer I insmoded the .ko and tried this, but there is no /var/log/messages. A google search told me that this had been renamed to /var/log/syslog, but looking in /var/log that does not seem to exist either. Why do I not have a log?

What I do see is the following:

Xorg.0.log
Xorg.0.log.old
apt
dmesg
dmesg.0
dmesg.1.gz
dmesg.2.gz
dmesg.3.gz
dmesg.4.gz
dpkg.log
dpkg.lob.1
dpkg.log.2.gz
lastlog
lightdm
pm-powersave.log
pm-powersave.log.1
pm-powersave.log.2.gz
pm-powersave.log.3.gz
pm-powersave.log.4.gz
samba
udev
unattended-upgrades
3
  • dmesg does have the printk, so that should work for me, thanks. Are there any differences I should be aware of between dmesg and messages?
    – Zephyr
    Aug 2, 2016 at 18:31
  • Which release ?
    – heemayl
    Aug 2, 2016 at 18:33
  • Always assume latest release if not told :+
    – Rinzwind
    Aug 2, 2016 at 18:37

1 Answer 1

7

/var/log/messages is not used in Ubuntu (it got removed around Natty). We use /var/log/syslog for that. Everything logged to 'messages' back then was also logged into 'syslog' so we got rid of one of them.

I do have a syslog and a kern.log in /var/log/. I would expect the last one to hold anything kernel related.

There is a better method: the journald daemon has all what has been logged.


You can list kernel messages with:

$ journalctl -f _TRANSPORT=kernel

That should show you anything related to the kernel and you can grep the results if need be. But there is a lot of options to refine your results (see the link or journalctl --help).

Other examples (from the link):

Without arguments, all collected logs are shown unfiltered:

journalctl

With one match specified, all entries with a field matching the expression are shown:

journalctl _SYSTEMD_UNIT=avahi-daemon.service

If two different fields are matched, only entries matching both expressions at the same time are shown:

journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097

If two matches refer to the same field, all entries matching either expression are shown:

journalctl _SYSTEMD_UNIT=avahi-daemon.service _SYSTEMD_UNIT=dbus.service

If the separator "+" is used, two expressions may be combined in a logical OR. The following will show all messages from the Avahi service process with the PID 28097 plus all messages from the D-Bus service (from any of its processes):

 journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097 + _SYSTEMD_UNIT=dbus.service

Show all logs generated by the D-Bus executable:

journalctl /usr/bin/dbus-daemon

Show all kernel logs from previous boot:

journalctl -k -b -1

Show a live log display from a system service apache.service:

journalctl -f -u apache

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .