Let's say you have a Node app running as service but you also want to save response in a custom log. Add following lines to your systemd service unit (/lib/systemd/system/myapp.service) file under the [Service] tag
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier='myapp'
Then reload systemd manager configuration
sudo systemctl daemon-reload
Open /etc/rsyslog.conf and uncomment the following lines to listen syslog service on port 514
# provides UDP syslog reception
#module(load="imudp")
#input(type="imudp" port="514")
# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")
Then restart the service and check if the listener on port 514
sudo systemctl restart rsyslog
netstat -an | grep "LISTEN "
Create /etc/rsyslog.d/myapp.conf file with contents below to tell rsyslog where it will save application log
sudo nano /etc/rsyslog.d/myapp.conf
if $programname == 'myapp' or $syslogtag == 'myapp' then /var/log/myapp/myapp.log
& ~
Restart rsyslog service again
sudo systemctl restart rsyslog
Restart your service again
sudo systemctl restart myapp