<div dir="ltr"><div dir="ltr">Regarding the below point :<div><div>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).</div><div><br></div></div><div>I did not see StandardOutput field in [Service] sections of a service file, for example sshd.service, but its logs are visible in journalctl.</div><div>Is it by default piped to journal and we need to explicitly mention it (StandardOutput=)  only when we want to redirect it somewhere else?</div><div><br></div><div>Even in my self made service I did not mention StandardOutput=, but I can see the logs in journalctl.</div><div><br></div><div>Is there a place where I can see .service file defaults ?</div><div><br></div><div>Nishant</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 20 Aug 2021 at 15:20, Mantas Mikulėnas <<a href="mailto:grawity@gmail.com">grawity@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Aug 20, 2021 at 12:31 PM Nishant Nayan <<a href="mailto:nayan.nishant2000@gmail.com" target="_blank">nayan.nishant2000@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Hi,<div dir="auto">    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.</div></div></blockquote><div><br></div><div>Journald doesn't talk to services, services talk to journald:</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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).</div><div><br></div><div>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.</div></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr">Mantas Mikulėnas</div></div></div>
</blockquote></div></div>