So, I'm using systemd to send the logs to rsyslog, and I want to write the logs to /var/log/app.log.
Since it is a Java app with its own log format, I don't want to have timestamps or anything on it, just the message itself.
What I have so far is this:
[Unit]
Description=My App
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=myapp
ExecStart=/usr/bin/java -jar /opt/app.jar
Restart=on-failure
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
And then I have thet /etc/rsyslog.d/myapp.conf file:
template(name="clean" type="string" string="%msg:2:$:drop-last-lf%\n")
if …Run Code Online (Sandbox Code Playgroud)