From Mageia wiki
Jump to: navigation, search


Drakconf multiflag.png
Other languages
english ; français ;
Synopsis:
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=

Or in short, to just see current boot just enter "-b". To see earlier boot before, add a relative number such as -1 for the boot before, so in total including the commmand

journalctl -b-1

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>

Configuration

It is in the file /etc/systemd/journald.conf – See journald.conf(5) for details.

Limiting log size

The default size is 10% of the partition. This is often unnecessarily large, and a large log also makes journalctl command quite slow.

In the configuration file, for example, change relevant lines to

SystemMaxUse=200M
RuntimeMaxUse=200M