Apache Tomcat for Windows


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.

This guide has been written for integration with 32 bit and 64 bit Windows machines.

Integration of Apache Tomcat Logs via NXLog with DNIF Adapter

To configure NXLog to send Apache Tomcat access logs to DNIF Adapter.

If you want to integrate Apache Tomcat access logs as well as Windows event logs, please refer our help guide: Integrating Windows Event Logs.

Download and install nxlog

Download and install the latest version of NXLog (Download Link) on the Windows machine from which the logs need to be collected.

After installation, find the nxlog.conf file in the C:\Program Files (x86)\nxlog\conf folder. In 32 bit Windows machines, look in the C:\Program Files\nxlog\conf folder

nxlog.conf file location

Open the nxlog.conf file using a text editor. Replace the entire configuration by copy-pasting the text given for your Windows version.

Windows 2008 x32 bit OS

#============ Define ROOT here ===================
define ROOT C:\Program Files\nxlog
#define ROOT C:\Program Files (x86)\nxlog
#============ NXLog Machine Log info =============
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log

#####for apache-tomcat access log################

<Extension syslog>
Module xm_syslog
</Extension>

<Input apache-tomcat-logs>
Module im_file
File 'C:\Users\Administrator\Downloads\apache-tomcat-7.0.37-windows-x64\apache-tomcat-7.0.37\logs\localhost_access_log.*'  ##path of log file
SavePos True
Recursive TRUE
PollInterval 1
Exec $Message=$raw_event;$SyslogFacilityValue=24;
</Input>

<Output out-apache-tomcat>
Module om_udp
Exec to_syslog_bsd();
Host DNIF-Adapter-IP
Port 514
</Output>

<Route 1>
Path apache-tomcat-logs => out-apache-tomcat
</Route>

Windows 2008 x64 bit OS

#============ Define ROOT here ===================
#define ROOT C:\Program Files\nxlog
define ROOT C:\Program Files (x86)\nxlog
#============ NXLog Machine Log info =============
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log

#####for apache-tomcat access log################

<Extension syslog>
Module xm_syslog
</Extension>

<Input apache-tomcat-logs>
Module im_file
File 'C:\Users\Administrator\Downloads\apache-tomcat-7.0.37-windows-x64\apache-tomcat-7.0.37\logs\localhost_access_log.*'  ##path of log file
SavePos True
Recursive TRUE
PollInterval 1
Exec $Message=$raw_event;$SyslogFacilityValue=24;
</Input>

<Output out-apache-tomcat>
Module om_udp
Exec to_syslog_bsd();
Host DNIF-Adapter-IP
Port 514
</Output>

<Route 1>
Path apache-tomcat-logs => out-apache-tomcat
</Route>

Restart NXLog

To apply changes made on nxlog.conf, you have to restart the service again. Go to Control Panel > Services and locate the nxlog service.

Right click on nxlog and restart

nxlog service restart

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