<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 27, 2021 at 1:11 PM Arjun D R <<a href="mailto:drarjun95@gmail.com">drarjun95@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">Hi Folks,<div><br></div><div>Currently we are using systemd-journald for service logging. We run journalctl for a bunch of services and redirect those to the custom log files for every few seconds. This takes up the CPU for that particular time period since we have lot of IO operations as well. We came to know that systemd version v236+ supports direct logging (StandardOutput:file:<log_file>) to the custom log file by the service. I would like to use that facility but we don't get the prefix that we used to get when using the journal. </div><div><br></div><div>Is there a way to prepare a custom patch locally to add the necessary prefix to the stdout before writing to the custom log file? Is that a good idea? Any other suggestions?</div></div></blockquote><div><br></div><div>Probably not easily, as it's not systemd that is writing to the log file – it's your service process itself that directly gets a FD for the log file as its stdout. It's not specifically a "direct logging" feature, but rather just an equivalent to `myservice > log_file`.</div><div><br></div><div>How do you currently get the logs "every few seconds"? Instead of repeated grabbing, have you tried using `journalctl --follow` to monitor logs continuously? This should use far less I/O than repeated `journalctl | tail` which is what it sounds like you're doing. (Wrap in `stdbuf -o0` if necessary.)<br></div><div><br></div><div>Alternatively, set up the traditional rsyslogd or syslog-ng – writing to custom log files is basically what they *do*, and both of them are capable of receiving logs from journald (either by directly monitoring .journal files or by having the messages forwarded via socket).<br></div></div><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>