如何让用户使用journalctl查看用户特定的系统服务日志?

我在Ubuntu 16.04 LTS中运行用户级服务。 例如,我有我的test.service位于〜/ .config / systemd / user / test.service

我能够通过做运行服务

systemctl --user start test.target 

但是,当我尝试使用journalctl读取其日志时,出现了以下错误消息:

 journalctl --user -u test.service Hint: You are currently not seeing messages from other users and the system. Users in the 'systemd-journal' group can see all messages. Pass -q to turn off this notice. No journal files were opened due to insufficient permissions. 

我怎样才能使用journalctl用户的特定单位?

在较旧的系统版本上,您将不得不使用journalctl --user --user-unit=SERVICENAME (在较新的版本上, journalctl --user -u SERVICENAME将正常工作)。

但是,这只有在/etc/systemd/journald.conf[Journal]部分的Storage指令设置为persistent (而不是autovolatile )时才有效。 编辑configuration文件后重新启动,用户将能够看到日志。

更多信息: https : //www.freedesktop.org/software/systemd/man/journald.conf.html https://lists.freedesktop.org/archives/systemd-devel/2016-October/037554.html