[systemd-devel] Trying to resolve user level systemd unit journal not writing to local user journal

SCOTT FIELDS Scott.Fields at kyndryl.com
Tue Aug 13 11:26:25 UTC 2024


Because of the documentation for the 'logsdirectory' option for unit files.

https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html

--

RuntimeDirectory=, StateDirectory=, CacheDirectory=, LogsDirectory=, ConfigurationDirectory=
These options take a whitespace-separated list of directory names. The specified directory names must be relative, and may not include "..". If set, when the unit is started, one or more directories by the specified names will be created (including their parents) below the locations defined in the following table. Also, the corresponding environment variable will be defined with the full paths of the directories. If multiple directories are set, then in the environment variable the paths are concatenated with colon (":").
Table 2. Automatic directory creation and environment variables
Directory       Below path for system units     Below path for user units       Environment variable set
RuntimeDirectory=       /run/   $XDG_RUNTIME_DIR        $RUNTIME_DIRECTORY
StateDirectory= /var/lib/       $XDG_STATE_HOME $STATE_DIRECTORY
CacheDirectory= /var/cache/     $XDG_CACHE_HOME $CACHE_DIRECTORY
LogsDirectory=  /var/log/       $XDG_STATE_HOME/log/    $LOGS_DIRECTORY
ConfigurationDirectory= /etc/   $XDG_CONFIG_HOME        $CONFIGURATION_DIRECTORY
--

Granted...this states the directory will be created in the case of user units...and does not state that it would actually put the log there. But it doesn't make a lot of sense to state the given behavior and not use it
________________________________
From: Andrei Borzenkov <arvidjaar at gmail.com>
Sent: Monday, August 12, 2024 11:08 PM
To: SCOTT FIELDS <Scott.Fields at kyndryl.com>; systemd-devel at lists.freedesktop.org <systemd-devel at lists.freedesktop.org>
Subject: [EXTERNAL] Re: [systemd-devel] Trying to resolve user level systemd unit journal not writing to local user journal

On 12.08.2024 22:36, SCOTT FIELDS wrote:
> OS = Fedora 39
> Systemd version = 254.13
>
> I have an application running via a user level system unit file.
>
> The UID is > 999.
>
> I'm expecting the application journal entries to be a local entry in $XDG_STATE_HOME/log, but it's using the user level journal in /var/log/journal.
>

Why do you expecting that?

> FYI, I'm not expressly setting XDG_STATE_HOME, since it heavily implies it will default to '$HOME /. local/state'
>
> I not yet tested expressly setting XDG_STATE_HOME in the unit file environment variables, since I really shouldn't have to.
>
> My understanding of the behavior is it SHOULD be writing this to the XDG_STATE_HOME location. If it's correct, how I can be troubleshoot why it's not?
>
>
> Scott Fields
>
> Kyndryl
>
> Senior Lead SRE – BNSF
>
> 817-593-5038 (BNSF)
>
> scott.fields at kyndryl.com<mailto:scott.fields at kyndryl.com>
>
> scott.fields at bnsf.com<mailto:scott.fields at bnsf.com>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20240813/aded225a/attachment.htm>


More information about the systemd-devel mailing list