Configuration guides for IT Administrators

Forward Tomcat logs to remote syslog

  1. Locate Tomcat Logs /opt/tomcat/logs/catalina.out
  2. Install rsyslog modules (if not already)
sudo yum list rsyslog rsyslog-mmnormalize
sudo yum update
sudo yum install rsyslog rsyslog-mmnormalize

3. Create Rulebase File

    For example: /etc/rsyslog.d/tomcat.rulebase

    rule=:%level:word% %rest:rest%
    1. Create rsyslog configuration

    For example: /etc/rsyslog.d/30-tomcat.conf

    module(load="imfile")
    module(load="mmnormalize")
    
    input(type="imfile"
          File="/opt/tomcat/logs/catalina.out"
          Tag="tomcat"
          Severity="info"      # Initial placeholder; will be overridden
          Facility="local6"
          Ruleset="tomcat-parse")
    
    parser(name="tomcat-parser" type="mmnormalize"
           rulebase="/etc/rsyslog.d/tomcat.rulebase")
    
    ruleset(name="tomcat-parse") {
      action(type="mmnormalize"
             parser="tomcat-parser")
    
      set $.sev = "6"   # default severity: info
      if $!level == "ERROR" then set $.sev = "3"
      if $!level == "WARN" then set $.sev = "4"
      if $!level == "DEBUG" then set $.sev = "7"
      if $!level == "INFO" then set $.sev = "6"
    
      call tomcat-out
    }
    
    ruleset(name="tomcat-out") {
      action(type="omfwd"
             target="your-syslog-server"
             port="514"
             protocol="udp"
             facility="local6"
             severity="$!$.sev")
    }
    1. Set Permissions
      sudo semanage fcontext -a -t var_log_t “/boxapps/apache/logs(/.*)?”
    2. is used in SELinux (Security-Enhanced Linux) to assign a file context type to a specific directory and its contents.
    PartMeaning
    sudoRun the command with superuser privileges
    semanage fcontextSELinux management command to define file contexts
    -aAdd a new file context mapping
    -t var_log_tAssign the SELinux type var_log_t, which is used for log files
    "/boxapps/apache/logs(/.*)?"Apply to /boxapps/apache/logs and all files/directories under it
    1. Restart rsyslog
    sudo systemctl restart rsyslog

    7. Use tcpdump to verify syslog traffic sudo tcpdump -i any udp port 514

    sudo tcpdump -i any udp port 514 and dst host x.x.x.x
      CodeSeverityMeaning
      0emergSystem is unusable
      1alertImmediate action required
      2critCritical conditions
      3errError conditions
      4warningWarning conditions
      5noticeNormal but significant event
      6infoInformational messages
      7debugDebug-level messages
      HostGator $2.75 per month
      HostGator
      24/7/365 Technical Support, Free Site Building Tools, 4500 Website Templates, Free Shopping Cart Software, Ideal for WordPress, 45 Day Money Back Guarantee
      FacilityCodeTypical Usage with Tomcat
      local016General application logging (default choice)
      local117Dedicated to Tomcat application logs
      local218Separate logs for different environments
      daemon3For system services like Tomcat daemon
      user1Default facility for user-level logs

      How does configuration is processed?

      When rsyslog starts, it processes its main configuration file:

      /etc/rsyslog.conf

      Within that file, you’ll typically find this line:

      $IncludeConfig /etc/rsyslog.d/*.conf

      This directive tells rsyslog to read and process all .conf files in /etc/rsyslog.d/, in lexicographical (alphabetical) order. So:

      01-base.conf is processed before 20-custom.conf

      z-final.conf is processed last

      All in One WordPress Hosting Starts at 30$ per month
      All in One WordPress Hosting
      WordPress
      High optimized WordPress hosting, secure firewall, HTTPS, Backup, hack-fix guarantee and many others at 30$ per month
      Categories: ,

      3 responses to “Forward Tomcat logs to remote syslog”

      1. 6x6betgame avatar

        Yo, 6x6betgame is where it’s at. Been hittin’ some nice wins lately. Give 6x6betgame a shot, might get lucky!

      2. golo777game avatar

        Golo777game’s got a few games that I’m really diggin’. Good place to kill some time, ya know? Head over to golo777game for some chill entertainment.

      3. 7kgame avatar

        7kGame has some quick games. If you like faster gameplay, I recommend checking out 7kgame!

      Leave a Reply to 6x6betgame Cancel reply

      Your email address will not be published. Required fields are marked *

      Lucas Brey

      I’m Lucas Brey, a travel blogger sharing practical guides, hidden gems, and honest tips from the road. Follow along for smart itineraries, great food finds, and stories worth bookmarking.

      Tags