[systemd-devel] How does journald talks to other services?
Nishant Nayan
nayan.nishant2000 at gmail.com
Fri Aug 20 11:10:48 UTC 2021
Regarding the below point :
c) The service prints to stdout/stderr, but systemd attaches the service's
stdout/stderr to a pipe which is read by journald (using
sd_journal_stream_fd(3) from libsystemd). See [Service] StandardOutput= in
systemd.service(5).
I did not see StandardOutput field in [Service] sections of a service file,
for example sshd.service, but its logs are visible in journalctl.
Is it by default piped to journal and we need to explicitly mention it
(StandardOutput=) only when we want to redirect it somewhere else?
Even in my self made service I did not mention StandardOutput=, but I can
see the logs in journalctl.
Is there a place where I can see .service file defaults ?
Nishant
On Fri, 20 Aug 2021 at 15:20, Mantas Mikulėnas <grawity at gmail.com> wrote:
> On Fri, Aug 20, 2021 at 12:31 PM Nishant Nayan <
> nayan.nishant2000 at gmail.com> wrote:
>
>> Hi,
>> My query is how does systemd-journald talk to other services so that
>> it stores their logs/output in journal files, which could be displayed
>> using journalctl utlity.
>>
>
> Journald doesn't talk to services, services talk to journald:
>
> a) The service uses the standard syslog(3) call to send basic messages
> through the /dev/log socket, where journald (or a traditional syslogd) is
> listening.
>
> b) The service uses sd_journal_print(3) from libsystemd to send structured
> messages through /run/systemd/journal/socket (systemd-journald.socket).
> Some frameworks, such as GLib, have their own implementations of this
> protocol without needing libsystemd.
>
> c) The service prints to stdout/stderr, but systemd attaches the service's
> stdout/stderr to a pipe which is read by journald (using
> sd_journal_stream_fd(3) from libsystemd). See [Service] StandardOutput= in
> systemd.service(5).
>
> d) Journald also reads kernel messages (dmesg) from the /dev/kmsg device.
> Programs can actually write to /dev/kmsg to generate dmesg messages and
> journald will capture them.
>
> --
> Mantas Mikulėnas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210820/5c273062/attachment.htm>
More information about the systemd-devel
mailing list