The systemd unit files for my Java apps (on Ubuntu 18.04) appear to be working - I had set stdout and stderr to be sent to syslog and the log entries were appearing in /var/log/syslog.
However I want to use dynamic names, hence I added /etc/rsyslog.d/10-myapp.conf containing:
$CreateDirs on
:programname, startswith, "myapp-" {
/var/log/apps/$programname.log
stop
}
I then restarted rsyslog....and got a file named $programname.log in the directory.
I suspect that there may be an issue with how I have specified the dynamic file name - I see elsewhere people using a different syntax for selecting the message along with %...% around the variable name. However trying the following (and restarting rsyslog) did not help:
:programname, startswith, "myapp-" {
"/var/log/apps/%programname%.log"
stop
}
That gave me a file named %programname%.log