<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 28, 2021, 06:07 Arjun D R <<a href="mailto:drarjun95@gmail.com">drarjun95@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you <span style="color:rgb(0,0,0);white-space:pre-wrap">Mantas for the details. </span><div>How do you currently get the logs "every few seconds"? </div><div>> Actually we have a script that will be triggered every 10 seconds. That script will run "journalctl -u <service>" and redirect the output to the respective log file. We will run journalctl for around 40-50 services for every 10 seconds and redirect it to the respective log files. That may be a bad idea, but this is how we are collecting logs as of now. We need to separate the logs for every service and that's why we ended up with this implementation. </div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">So replace it with 40-50 instances of continuously running `[stdbuf -o0] journalctl -f -u <service>`.</div><div dir="auto"><br></div><div dir="auto">Although syslogd might be easier, since then you'd only need one process doing the monitoring. (I know both syslogds can access journal fields like _SYSTEMD_UNIT, but I don't know how, so usually I just filter by the traditional "program name" and it does the job.)</div><div dir="auto"><br></div><div dir="auto">You could also have a custom daemon that reads from `journalctl -f -o json` and writes to the appropriate text log...</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><br></div><div>Ah, ok so StandardOutput:file:<log_file> will allow the service to open the fd and directly connect it to the service stdout.<br></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Yes, so if you want timestamps they have to be provided by your service, pretty much like how most services implement direct logging to files. (Probably the only advantage of StandardOutput is that the service doesn't need permissions to /var/log...)</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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">
</blockquote></div>
</blockquote></div></div></div>