Tomcat for linux


Apache Tomcat, often referred to as Tomcat, is an open-source web server developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket, and provides a “pure Java” HTTP web server environment in which Java code can run.

Integration of Tomcat on ubuntu with DNIF Adapter

To forward Tomcat logs to the DNIF Adapter make the following configuration.

Install syslog package, if you haven’t installed it.

apt-get install rsyslog

Setup Tomcat Access Logs, if you haven’t enable it.

This is done by enabling the access logs in server.xml located at /etc/tomcat7/server.xml and configuring it for file monitoring.

Uncomment the following section in /etc/tomcat7/server.xml

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log." suffix=".txt"
       pattern="%h %l %u %t "%r" %s %b"/>

Restart tomcat service

service tomcat7 restart

Checking the rsyslog.conf

Open a rsyslog.conf file located at /etc/rsyslog.conf by following command

vim /etc/rsyslog.conf

At the end of the file check for the following line and uncomment

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

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf

Save and Quit the configuration file.

Create log configuration for Tomcat with vim /etc/rsyslog.d/tomcatlog.conf and paste following lines below

$ModLoad imfile

# localhost_access_log.txt
$InputFileName /var/log/tomcat7/localhost_access_log.*   ##Path of log file
$InputFileTag Tomcat-access:
$InputFileStateFile stat-tomcat-access
$InputFileSeverity info
$InputFileFacility local4
$InputRunFileMonitor

local4.*        @DNIF-Adapter-IP:514

Save and Quit the configuration file.

Restart rsyslog service

service rsyslog restart

Tomcat access logs are now being streamed to the DNIF-ADAPTER.

Integration of Tomcat on CentOS-RHEL with DNIF Adapter

To forward Tomcat logs to the DNIF Adapter make the following configuration.

Install rsyslog version 8.5.0 or higher is required because wildcard does not support in lower versions of rsyslog.

Download the rsyslog v8-stable version in path ‘/var/tmp/’.

wget http://rpms.adiscon.com/v8-stable/rsyslog.repo
mv rsyslog.repo /etc/yum.repos.d/
yum update
yum –y install rsyslog

Setup Tomcat Access Logs, if you haven’t enable it.

This is done by enabling the access logs in server.xml located at /etc/tomcat7/server.xml and configuring it for file monitoring.

Uncomment the following section in /etc/tomcat7/server.xml

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log." suffix=".txt"
       pattern="%h %l %u %t "%r" %s %b"/>

Restart tomcat service

service tomcat7 restart

Checking the rsyslog.conf

Open a rsyslog.conf file located at /etc/rsyslog.conf by following command

vim /etc/rsyslog.conf

At the end of the file check for the following line and uncomment

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

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf

Save and Quit the configuration file.

Create log configuration for Tomcat with vim /etc/rsyslog.d/tomcatlog.conf and paste following lines below

$ModLoad imfile

# localhost_access_log.txt
$InputFileName /var/log/tomcat7/localhost_access_log.*   ##Path of log file
$InputFileTag Tomcat-access:
$InputFileStateFile stat-tomcat-access
$InputFileSeverity info
$InputFileFacility local4
$InputRunFileMonitor

local4.*        @DNIF-Adapter-IP:514

Save and Quit the configuration file.

Restart rsyslog service

service rsyslog restart

Tomcat access logs are now being streamed to the DNIF-ADAPTER.