Re: [systemd-devel] How to allow a user to use journalctl to see user-specific systemd service logs?

2016-10-05 Thread Lennart Poettering
On Mon, 03.10.16 14:59, Daniel Ng (danieln...@gmail.com) wrote:

> I am running user-level services in Ubuntu 16.04 LTS.  For example, I have
> my test.service located at ~/.config/systemd/user/test.service
> 
> I was able to run the service by doing
> 
> systemctl --user start test.target
> 
> 
> However, when I try to read its log using journalctl, I got this error
> message:
> 
> 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.

On very recent systemd versions "journalctl --user -u SERVICENAME"
should just work as you think. On older versions you have to use
"--user --user-unit=SERVICENAME" instead.

> How can I use journalctl for user's specific unit?

Also, note that you ned perms to the journal for this to work. If you
are root or part of the "systemd-journal" system group, then you are
able to see all logs, regardless which subsystem or which user
generated them. If you are neither root, nor in that group you will
only get to see logs generated by processes you run under your own
user ID. However, this only works if the persistent logging is enabled
on your system, it does not work if only volatile logging is enabled
(check Storage= in journald.conf regarding this).

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to allow a user to use journalctl to see user-specific systemd service logs?

2016-10-03 Thread Daniel Ng
I actually meant to say "systemctl --user start test.*service*"
In Ubuntu 16.04 system with systemd 229, I was able to bypass the
permission error by adding the user to group "adm", but now the user can
see the journal of system units as  well.

One weird thing now is that
"journalctl --user-unit test.service" will only show systemd message, not
the stdout / stderr of the test process

for example:
Sep 30 23:09:14 hostname systemd[10551]: Stopped a test service.
Sep 30 23:09:46 hostname systemd[10551]: Started a test service.


This is my test.service
[Unit]
Description=a test service

[Service]
ExecStart=/bin/echo test something

[Install]
WantedBy=default.target



According to #3281 , it
seems this could be solved by changing the journal store to non-volatile.
I am going to try it.

On Mon, Oct 3, 2016 at 5:13 PM, Stefan Schweter  wrote:

> On 03.10.2016 20:59, Daniel Ng wrote:
>
> > 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.
> >
>
> I could reproduce the problem on a Ubuntu 16.04 system with systemd 229.
>
> Please also have a look at this issue on GitHub [1].
>
> Regards,
>
> Stefan
>
> [1] https://github.com/systemd/systemd/issues/3281
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to allow a user to use journalctl to see user-specific systemd service logs?

2016-10-03 Thread Stefan Schweter
On 03.10.2016 20:59, Daniel Ng wrote:

> 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.
> 

I could reproduce the problem on a Ubuntu 16.04 system with systemd 229.

Please also have a look at this issue on GitHub [1].

Regards,

Stefan

[1] https://github.com/systemd/systemd/issues/3281
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to allow a user to use journalctl to see user-specific systemd service logs?

2016-10-03 Thread Mantas Mikulėnas
On Mon, Oct 3, 2016 at 9:59 PM, Daniel Ng  wrote:

> I am running user-level services in Ubuntu 16.04 LTS.  For example, I have
> my test.service located at ~/.config/systemd/user/test.service
>
> I was able to run the service by doing
>
> systemctl --user start test.target
>
>
> However, when I try to read its log using journalctl, I got this error
> message:
>
> journalctl --user -u test.service
>

The option is --user-unit. -u always refers to system units.

-- 
Mantas Mikulėnas 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to allow a user to use journalctl to see user-specific systemd service logs?

2016-10-03 Thread Stefan Schweter
On 03.10.2016 20:59, Daniel Ng wrote:
> I am running user-level services in Ubuntu 16.04 LTS.  For example, I have
> my test.service located at ~/.config/systemd/user/test.service
>
> I was able to run the service by doing
>
> systemctl --user start test.target
>

Hi Daniel,

did you really use test.target? Target files are usally used for
grouping units [1].

I tried to create a test.service file in ~/.config/systemd/user and
started it with:

systemctl --user start test.service

Then it is possibly to use journalctl --user both with:

journalctl --user -u test

journalctl --user -u test.service

Tested with systemd 231 - what systemd version do you use?

Cheers,

Stefan

[1] https://www.freedesktop.org/software/systemd/man/systemd.target.html

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel