27

I'd like to get the current configuration of journald, similarly to question How to view systemd's runtime global config?

How can I do this?

Specifically, I have set some of the available parameters for log rotation but journald seems to obey other values. I would like to see the current values of all parameters (SystemMaxUse, SystemMaxFileSize, etc) to have a better understanding of what limits the current log retention. For now, I only have the message given by journald at startup:

System journal [...] is 5.8G, max 12.0G, 6.1G free.

3 Answers3

8

I think what you are looking for is systemd-analyze cat-config systemd/journald.conf.  It will show you the currently active configuration as used by systemd-journald.

Robert
  • 181
7

To get half way there, run

journalctl -u systemd-journald -o json-pretty

json-pretty output formatter will show all fields associated with the log message. There are MAX_USE_PRETTY and MAX_USE fields, which represent SystemMaxUse. You could alse patch server_space_usage_message.

2

Here's hoping I understand your question correctly, this is what I found in the man pages for journald config: journald.conf(5)

CONFIGURATION DIRECTORIES AND PRECEDENCE

    The default configuration is defined during compilation, so a configuration file is only needed when it is necessary to deviate from those defaults.  By default, the configuration file in /etc/systemd/ contains commented out entries showing the defaults as a guide to the administrator. This file can be edited to create local overrides.

This would mean that you have all the defaults already in the config file mentioned. However, some options, specifically the ones you're looking for about max size, are not filled in.

There's a difference between "persistent" and "auto/runtime" storage mode.

Here's what I find below:

SystemMaxUse=, SystemKeepFree=, SystemMaxFileSize=, SystemMaxFiles=, RuntimeMaxUse=RuntimeKeepFree=, RuntimeMaxFileSize=, RuntimeMaxFiles=

    Enforce size limits on the journal files stored. The options prefixed with "System" apply to the journal files when stored on a persistent file system, more specifically /var/log/journal. The options prefixed with "Runtime" apply to the journal files when stored on a volatile in-memory file system, more specifically /run/log/journal. The former is used only when /var is mounted, writable, and the directory /var/log/journal exists. Otherwise, only the latter applies. Note that this means that during early boot and if the administrator disabled persistent logging, only the latter options apply, while the former apply if persistent logging is enabled and the system is fully booted up. …

and followed by this:

    The first pair defaults to 10% and the second to 15% of the size of the respective file system, but each value is capped to 4G. If the file system is nearly full and either SystemKeepFree= or RuntimeKeepFree= are violated when systemd-journald is started, the limit will be raised to the percentage that is actually free. …

The man-page for journald.conf goes on about these settings so I think it'd be best and more up-to-date for the version you run if you check the man page that's actually on your own system.

About log rotation, I'm assuming you're asking about the journal logs and not about the logrotate-service? The former is also in the man-pages and it's called "vacuum cleaning" while the latter is a different service.

Systemd offers the possibility to replace the old logrotations via cron jobs with "timer" services to do the same. The timers can be found like this: sudo systemctl list-timers --all --no-pager and timers can be enabled using normal "sytemctl enable" commands, etc.

lievendp
  • 121
  • 1
    That's right. I just wanted to understand a difference between what the running instance parameters and the values I thought it would use, based on my reads. The log rotation part was about the creation of new log files after a certain amount of time or size, based on these parameters. – Christophe Drevet Oct 15 '20 at 11:51