'SOLVED- Tomcat 9. How to pass catalina.out to service logs (journalctl)
I'm using Tomcat 9 in a Centos machine. The logs from Tomcat applications are generated at /opt/tomcat/logs.catalina.out. Is there a way to pass these logs to service logs (journalctl -u MyTomcat.service -f)?
I trigger my service from /etc/systemd/system.MyTomcat.service
ExecStart=/opt/tomcat/startup.sh (startup.sh call catalina.sh start)
I'm able to see the logs in catalina.out but journcalctl has only these rows but catalina includes all the logging from my apps
Feb 28 08:14:39 192.168.1.2 systemd[1]: Starting My Tomcat Service...
Feb 28 08:14:39 192.168.1.2systemd[1]: Started My Tomcat Service.
Feb 28 08:14:39 192.168.1.2tomcat[23222]: Tomcat started.
Solution 1:[1]
Hi i found a solution for the post. Here is what I did if there is someone else that is looking for it.
1. /etc/rsyslog.conf
#add imfile module
$ModLoad imfile
$IncludeConfig /etc/rsyslog.d/*.conf
...
*.* @@<SYSLOG_SERVER ADDRESS>:<SYSLOG SERVER PORT>
2. /etc/rsyslog.d/catalina_ruleset.conf
template(
name = "my_template"
type = "string"
string = "<%PRI%>%timegenerated% %HOSTNAME% %syslogtag%: %msg%"
)
input(
type="imfile"
File="<catalina.out location>"
Tag="MyTag"
PersistStateInterval="1"
reopenOnTruncate="on"
freshStartTail="on"
ruleset="My_ruleset"
)
ruleset(name="My_ruleset") {
action(
type="omfwd"
template=""my_template""
queue.saveonshutdown="on"
action.resumeRetryCount="-1"
Target="<SYSLOG_SERVER ADDRESS>"
Port="<SYSLOG SERVER PORT>"
Protocol="tcp"
)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nakos Kotsanis |
