小编caa*_*os0的帖子

rsyslog: send logs to different file using custom template

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)

rsyslog syslog systemd

2
推荐指数
1
解决办法
1987
查看次数

标签 统计

rsyslog ×1

syslog ×1

systemd ×1