How to redirect Tomcat logs back to catalina.out instead of syslog?

5,071

Tomcat being installed from openSUSE repo runs as a service under systemd. According to this page, it is not possible to redirect output of systemd-controlled services directly to the file. Thus, I have the only option left: filter messages from syslog when they got there.

I have created file /etc/rsyslog.d/tomcat.conf and put these lines there:

:programname,contains,"tomcat" /var/log/tomcat/tomcat.log

:programname,contains,"tomcat" ~

This works fine for me.

UPD 2018: Nowdays every developer would rather have own Tomcat instance unpacked into a folder, not installed system wide. Or even one embedded into the program, that could be done in Spring Boot for example.

Share:
5,071

Related videos on Youtube

no id
Author by

no id

Updated on September 18, 2022

Comments

  • no id
    no id over 1 year

    In the release notes for openSUSE 13.1, developers proudly stated that Tomcat logs are no longer being written into catalina.out, but rather written to syslog. I saw similar behaviour with new distributions, but now it's my problem also. I really don't know why it is considered as improvement. And that's why,

    1. My Tomcat installation is used as a playground for several developers, and I hardly want to share my syslog with them.
    2. The webapp under Tomcat is pretty verbose with logs (since it is under development) and I don't want to put all these garbage in to the syslog.

    There are a plenty of tutorials on how to redirect Tomcat log into syslog, but I need to perform reverse operation. Any ideas?

    UPD: Here is my tomcat.conf, nothing suspicious there:

    JAVA_HOME="/etc/alternatives/jre"

    CATALINA_HOME="/usr/share/tomcat" CATALINA_BASE="/usr/share/tomcat" CATALINA_TMPDIR="/var/cache/tomcat/temp"

    SECURITY_MANAGER="false"

    SHUTDOWN_WAIT="30"

    SHUTDOWN_VERBOSE="false"

    CLEAR_WORK="false"

    CATALINA_OPTS="-Xms2G -Xmx8G -XX:PermSize=256m -XX:MaxPermSize=4G"

    • S edwards
      S edwards about 10 years
      what is your tomcat config ? (not oblige to put every virtual host)
    • S edwards
      S edwards about 10 years
      does the catalina.sh still present ?
    • no id
      no id about 10 years
      Yes, it's present. I have found some acceptable solution. I will publish it in a couple of minutes.
  • Phil
    Phil about 9 years
    Any idea how to do this for syslog-ng?