8 cfg = config.services.journald;
12 (lib.mkRenamedOptionModule
13 [ "services" "journald" "enableHttpGateway" ]
14 [ "services" "journald" "gateway" "enable" ]
19 services.journald.console = lib.mkOption {
22 description = "If non-empty, write log messages to the specified TTY device.";
25 services.journald.rateLimitInterval = lib.mkOption {
29 Configures the rate limiting interval that is applied to all
30 messages generated on the system. This rate limiting is applied
31 per-service, so that two services which log do not interfere with
32 each other's limit. The value may be specified in the following
33 units: s, min, h, ms, us. To turn off any kind of rate limiting,
34 set either value to 0.
36 See {option}`services.journald.rateLimitBurst` for important
37 considerations when setting this value.
41 services.journald.storage = lib.mkOption {
42 default = "persistent";
43 type = lib.types.enum [
50 Controls where to store journal data. See
51 {manpage}`journald.conf(5)` for further information.
55 services.journald.rateLimitBurst = lib.mkOption {
59 Configures the rate limiting burst limit (number of messages per
60 interval) that is applied to all messages generated on the system.
61 This rate limiting is applied per-service, so that two services
62 which log do not interfere with each other's limit.
64 Note that the effective rate limit is multiplied by a factor derived
65 from the available free disk space for the journal as described on
67 journald.conf(5)](https://www.freedesktop.org/software/systemd/man/journald.conf.html).
69 Note that the total amount of logs stored is limited by journald settings
70 such as `SystemMaxUse`, which defaults to 10% the file system size
71 (capped at max 4GB), and `SystemKeepFree`, which defaults to 15% of the
74 It is thus recommended to compute what period of time that you will be
75 able to store logs for when an application logs at full burst rate.
76 With default settings for log lines that are 100 Bytes long, this can
77 amount to just a few hours.
81 services.journald.extraConfig = lib.mkOption {
83 type = lib.types.lines;
84 example = "Storage=volatile";
86 Extra config options for systemd-journald. See {manpage}`journald.conf(5)`
87 for available options.
91 services.journald.forwardToSyslog = lib.mkOption {
92 default = config.services.rsyslogd.enable || config.services.syslog-ng.enable;
93 defaultText = lib.literalExpression "services.rsyslogd.enable || services.syslog-ng.enable";
94 type = lib.types.bool;
96 Whether to forward log messages to syslog.
102 systemd.additionalUpstreamSystemUnits =
104 "systemd-journald.socket"
105 "systemd-journald@.socket"
106 "systemd-journald-varlink@.socket"
107 "systemd-journald.service"
108 "systemd-journald@.service"
109 "systemd-journal-flush.service"
110 "systemd-journal-catalog-update.service"
111 "systemd-journald-sync@.service"
113 ++ (lib.optional (!config.boot.isContainer) "systemd-journald-audit.socket")
115 "systemd-journald-dev-log.socket"
120 "systemd/journald.conf".text = ''
122 Storage=${cfg.storage}
123 RateLimitInterval=${cfg.rateLimitInterval}
124 RateLimitBurst=${toString cfg.rateLimitBurst}
125 ${lib.optionalString (cfg.console != "") ''
127 TTYPath=${cfg.console}
129 ${lib.optionalString (cfg.forwardToSyslog) ''
136 users.groups.systemd-journal.gid = config.ids.gids.systemd-journal;
138 systemd.services.systemd-journal-flush.restartIfChanged = false;
139 systemd.services.systemd-journald.restartTriggers = [
140 config.environment.etc."systemd/journald.conf".source
142 systemd.services.systemd-journald.stopIfChanged = false;
143 systemd.services."systemd-journald@".restartTriggers = [
144 config.environment.etc."systemd/journald.conf".source
146 systemd.services."systemd-journald@".stopIfChanged = false;