Home:ALL Converter>Forwarding logs from file to journald

Forwarding logs from file to journald

Ask Time:2017-02-22T20:19:46         Author:Rahul

Json Formatter

I have an application on the isolated machine. It writes logs to /var/log/app/log.txt for example. However, I want it to write logs to journald daemon. However, I can't change the way application run, because it is encapsulated.

I mean I can not do smth like app | systemd-cat

1) Am I right that all services started with systemd write logs to journald?

2) If so, will the children of process, started by systemd, will also write logs to journald?

3) Is there any way to tell journald to take logs from a specific file?

4) If not, are there any workarounds?

Author:Rahul,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/42391313/forwarding-logs-from-file-to-journald
AbdulKareem :

warning: this is not tested\n\nYou could mount bind /dev/stdout to log file in ExecStartPre\n\nExample:\n\nExecStartPre=/use/sbin/mount --bind /dev/stdout  /var/log/app/log.txt\n\n\nOr soft link /dev/stdout to log file in ExecStartPre\n\nExample:\n\nExecStartPre=/use/bin/ln -s /dev/stdout  /var/log/app/log.txt\n",
2017-02-24T17:10:33
yy