From Mageia wiki
Revision as of 10:29, 10 October 2017 by Inktvis75 (talk | contribs) (Unit State)
Jump to: navigation, search


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.

Unit State

Daemons, scripts, timers and many other things are started by systemD units. To get a complete list of all units that are active:

systemctl list-units

If you want a list of the services, just add --type service

To get the state of a unit, execute:

systemctl status <unit>

e.g.

systemctl status sshd

It will not only show the state of the service but also the last 10 entries of the journal log

Journal

Everything is logged into a database that can be queried.

To view all the logging:

journalctl

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)

journalctl --dmesg

Boot sessions

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:

journalctl --list-boots

You can limit your search with the parameter

--boot=

Tail

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:

journalctl -f

To go to the end of the logging database, use the -e parameter.

'Hidden parameters'

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>