8

I have a RHEL7 server with Apache Tomcat 7.0 installed and after a recent update to RHEL7.1 all of the logging to ${catalina.base}/logs/catalina.out was stopped. However I am receiving the logs inside journalctl.

If I type journalctl -u tomcat I do get the logging. Is there any way for me to get the logging also to catalina.out?

cat /usr/share/tomcat/logs/catalina.out
no output

journalctl -u tomcat

Aug 20 10:07:14 server.example.com server[26435]: at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
Aug 20 10:07:14 server.example.com server[26435]: at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
Aug 20 10:07:14 server.example.com server[26435]: at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
Aug 20 10:07:14 server.example.com server[26435]: at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
Aug 20 10:07:14 server.example.com server[26435]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
Aug 20 10:07:14 server.example.com server[26435]: at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
Aug 20 10:07:14 server.example.com server[26435]: at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
...
  • Have you verified that the variable "catalina.base" is set correctly? – VGe0rge Aug 20 '15 at 10:37
  • Yes the catalina.base is set correctly. jinfo -sysprops 26435 | grep catalina.base catalina.base = /usr/share/tomcat – xterrez Aug 20 '15 at 12:47
  • You could try to see of the file is opened at all by the tomcat process. Try to stat /usr/share/tomcat/logs/catalina.out – VGe0rge Aug 20 '15 at 13:15
  • No, that tomcat process is not using the catalina.out file. stat /usr/share/tomcat/logs/catalina.out File: ‘/usr/share/tomcat/logs/catalina.out’ Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fd01h/64769d Inode: 1013845 Links: 1 Access: (0660/-rw-rw----) Uid: ( 91/ tomcat) Gid: ( 91/ tomcat) Access: 2015-08-19 11:21:32.835211998 +0000 Modify: 2015-08-17 03:40:02.785809293 +0000 Change: 2015-08-17 03:40:02.785809293 +0000 Birth: - – xterrez Aug 20 '15 at 14:55
  • Ok, try to add the absolute path in the tomcat conf file and restart the service. Then retry the stat commands to see the results. – VGe0rge Aug 20 '15 at 23:09
10

Jamie's answer is correct that you can force rsyslog to log what's going on with tomcat. However, that doesn't answer why tomcat 7 on rhel 7 does not log to catalina.out. Or if it does, why does it log to both catalina.out and a catalina with a date (if you are not using an RPM install).

First, in the past around 7.0.42, Red Hat's scripts used catalina.out because their scripts were mimicking behavior of RHEL 6. As far as I'm aware, they were using "forking" for the service for systemd. When 7.0.56 was released, they changed that entirely by making new scripts and wrappers in /usr/libexec/tomcat to force tomcat to run in simple mode instead of forked, allowing systemd to have control of the PID and stdout and stderr to go to the journal. There is still a catalina.$DATE.log file in /var/log/tomcat, but the information is more limited from a normal catalina.out.

Second, let's look at /etc/tomcat/logging.properties. You'll see it sorts out the logs in a specific way between catalina, localhost, manager, host-manager. You'll also notice that it has rsyslog facility support too, and basically how it "deals" with it. What it comes down to is the ConsoleHandler in that file. Changing those would change the behavior of the logs in /var/log/tomcat.

journalctl -u tomcat will show you everything that catalina.out is supposed to have. As far as I'm aware, without modifying Red Hat's wrappers in /usr/libexec/tomcat, there isn't a sure fire way to make everything go to just catalina.out. If you do modify those scripts and an update comes out, your changes will be overwritten.

If you want catalina.out for sure, go with Jamie's rsyslog example configuration. Just know that it will not only fill that, but the systemd journal will also have the same information.

  • Good answer! It has me thinking about making incompatible changes between Tomcat releases... :| – RockyMM Jan 23 '17 at 15:58
6

Creating a new file /etc/rsyslog.d/tomcat.conf containing the next two lines did the trick for me:

programname,contains,"server" /var/log/tomcat/catalina.out
programname,contains,"server" ~

Afterwards restart your rsyslog daemon:

service rsyslog restart
0

It seems the rsyslog syntax changed with the newer versions. Running 8.24.0 on RHEL 7.4, the following syntax in /etc/rsyslog.d/tomcat.conf got it to work for me:

if ($programname contains "server") then {
    action(type="omfile" file="/var/log/tomcat/catalina.out" flushOnTXEnd="off")
    stop
}

Then, as Jaimie points out restart of rsyslog was needed:

service rsyslog restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.