Forward log messages from an application in a separate logfile using rsyslog

Open /etc/rsyslog.conf and add to the end:

# define template name and logfile where application logs will be forwarded
$template testapp, "/var/log/testapplog"

# if application name is 'testapp' then apply the above defined template
if $programname contains 'testapp' then ?testapp

# prevent messages that matched the condition on above line to be processed further
# without this line, the message will end up in /var/log/testapplog and in /var/log/messages.
& ~
Restart rsyslog after making the above changes:
$ sudo systemctl restart rsyslog
Generate a test message from app testapp:
$ logger -i -t testapp testmessage
After that, you can find a logfile with message in it:
$ sudo ls -la /var/log/testapplog 
-rw-r----- 1 root adm 49 Dec  9 21:48 /var/log/testapplog
$ sudo tail /var/log/testapplog 
Dec  9 21:48:58 db testapp[3011931]: testmessage