- /etc/logrotate.d/tomcat9
- /etc/rsyslog.d/tomcat9.conf
The changes in the logrotate configuration are pretty simple: replace sysadm adm or tomcat adm with xnat xnat. For rsyslog, edit that file to look like this (there will be more lines in there, just modify the last part):
:programname, startswith, "tomcat9” {
action(type="omfile" file="/var/log/tomcat9/catalina.out" Template="TomcatFormat" fileOwner="xnat" fileGroup="xnat" fileCreateMode=“0640”)
}
Basically you’re just adding the fileOwner and fileGroup attributes to that action line.
I stopped Tomcat, deleted everything under /var/log/tomcat9, changed ownership of that folder to xnat:xnat, restarted logrotate and rsyslog, then restarted Tomcat, and voila:
# find /var/log/tomcat9 -ls
420972 4 drwxr-xr-x 2 xnat xnat 4096 Feb 20 11:59 /var/log/tomcat9
422995 8 -rw-r----- 1 xnat xnat 5508 Feb 20 11:59 /var/log/tomcat9/catalina.2023-02-20.log
427898 0 -rw-r----- 1 xnat xnat 0 Feb 20 11:59 /var/log/tomcat9/localhost.2023-02-20.log
427916 0 -rw-r----- 1 xnat xnat 0 Feb 20 11:59 /var/log/tomcat9/localhost_access_log.2023-02-20.txt