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.
Below is an Apache Tomcat log sample consisting of three events. The log message of the second event spans multiple lines.
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.
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>