NXLog Docs

Apache Tomcat

Apache Tomcat is an open-source implementation of the Jakarta Servlet, Jakarta Server Pages, Jakarta Expression Language, Jakarta WebSocket, Jakarta Annotations, and Jakarta Authentication specifications. See logging in the Apache Tomcat Documentation for detailed logging information. This guide provides an overview of collecting and parsing Apache Tomcat logs with NXLog.

Example 1. Collecting Apache Tomcat logs

Below is an Apache Tomcat log sample consisting of three events. The log message of the second event spans multiple lines.

Apache Tomcat log sample
2001-01-25 17:31:42,136 INFO [org.nxlog.somepackage.Class] - single line
2001-01-25 17:41:16,268 ERROR [org.nxlog.somepackage.Class] - Error retrieving names: ; nested exception is:
        java.net.ConnectException: Connection refused
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.net.ConnectException: Connection refused
 faultActor:
 faultNode:
 faultDetail:
        {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection refused
2001-01-25 17:57:38,469 INFO [org.nxlog.somepackage.Class] - third log message

The xm_multiline module is used to parse and process multiple line log messages. In this example, a regular expression match determines the beginning of a log message.

nxlog.conf
define REGEX   /(?x)^(?<EventTime>\d{4}\-\d{2}\-\d{2}\ \d{2}\:\d{2}\:\d{2}),\d{3}\ \
               (?<Severity>\S+)\ \[(?<Class>\S+)\]\ \-\ (?<Message>[\s\S]+)/

<Extension multiline>
    Module        xm_multiline
    HeaderLine    %REGEX%
</Extension>

<Input log4j>
    Module        im_file
    File          '/opt/tomcat/logs/catalina.out'
    InputType     multiline
    Exec          if $raw_event =~ %REGEX%  $EventTime = parsedate($EventTime);
</Input>
Disclaimer

While we endeavor to keep the information in this topic up to date and correct, NXLog makes no representations or warranties of any kind, express or implied about the completeness, accuracy, reliability, suitability, or availability of the content represented here. We update our screenshots and instructions on a best-effort basis.

The accurateness of the content was tested and proved to be working in our lab environment at the time of the last revision with the following software versions:

NXLog version 5.4.7313
Apache Tomcat version 10.0.20

Last revision: 05 May 2022