To troubleshoot your installation, to verify if everything is working correctly or just because you're curious, logging is an important topic.
The purpose of this command is not to give you a complete manual of all the available options, but will give you the most important ones.
Logging in general
There are two types of logging available on your system:
- Applications that create their own logfile(s) in /var/log
- The logging journal
This document is about the journal.
Daemons, scripts, timers and many other things are started by systemD units. To get a complete list of all units that are active:
If you want a list of the services, just add --type service
To get the state of a unit, execute:
systemctl status <unit>
systemctl status sshd
It will not only show the state of the service but also the last 10 entries of the journal log
Everything is logged into a database that can be queried.
To view all the logging:
The full log of a specific unit:
journalctl -u <unit>
You can be more specific, some examples:
journalctl -u <unit> --since 10:00 --until 12:00
journalctl -u <unit> --priority=err
To see more details, add the parameters:
--catalog --full --output=verbose
To view the kernel messages (similar to the old dmesg command)
By default configuration in Mageia is a persistent journal, so you can see the logging across reboots.
To view your current boot id, execute the command:
hostnamectl status | grep Boot
To see all the boot sessions:
You can limit your search with the parameter
With normal logfiles it's very common to limit the output with the tail command:
tail -n 20 <logfile>
Will give jou the last 20 lines of the output, for journalctl it's the same:
journalctl -n 20
Also the monitor option of tail: tail -f is the same:
To go to the end of the logging database, use the -e parameter.
The journactl utility has also some, sort of, hidden parameters, they start with an underscore. Type journactl _ and press the tab-key.
For instance: you want to view the messages from a specific process, just use pgrep or ps to find the process and view the log:
journalctl _PID=<process id>