Apache Tomcat

Configure Apache Tomcat Log Source with BindPlane

356

Supported Versions

Apache Tomcat versions

  • 8
  • 8.5
  • 9
  • 10

Configuration

OptionDescriptionLog Source
Log SourceUse this field to specify where your logs are coming from. When choosing the 'file' option, the agent reads logs from the log paths specified below. When choosing the 'Kubernetes' options, the agent reads logs from /var/log/containers based on the Pod and Container specified below.--
Log FormatWhen choosing the 'default' option, the agent will expect and parse logs in a format that matches the default logging configuration. When choosing the 'observIQ' option, the agent will expect and parse logs in an optimized JSON format that adheres to the observIQ specification.'file' or 'kubernetes'
Pod NameSpecify the Pod(s) running Apache Tomcat.'kubernetes'
Container NameSpecify the Container(s) running NGINX. Typically, you can leave this as the default value of (*) and specify the Pod(s) above.'kubernetes'
Access LogsEnable and specify the path to the Apache Tomcat Access logs

Note: you will only need to specify this path when using choosing 'file' as the Log Source.
'file' or 'kubernetes'
Catalina LogsEnable and specify the path to the Apache Tomcat Catalina Logs.

Note: you will only need to specify this path when using choosing 'file' as the Log Source.
'file' or 'kubernetes'
Start AtChoose whether to start reading from the beginning or end of a file.'file' or 'kubernetes'

Log Types

Types
tomcat.access
tomcat.catalina

Log Formats

Default: If you're using the default logging configuration for Apache Tomcat, choose the default Log Format option in the Source configuration.

observIQ: For optimal Apache Tomcat parsing and enrichment, we recommend choosing the 'observIQ' log format, and updating your server.xml file using the below steps:

  1. Edit Tomcat's server.xml
  2. Find the org.apache.catalina.valves.AccessLogValve section
  3. Set suffix to ".json"
  4. Set the Log Format listed below (Tomcat uses " in place of double quotes)
  5. Restart Tomcat
  6. Access log files will now use the .json suffix
prefix="localhost_access_log" suffix=".json"
pattern="{
    "remote_host": "%h",
    "timestamp": "%t",
    "remote_user": "%u",
    "user_session_id": "%S",
    "method": "%m",
    "path": "%U",
    "status": "%s",
    "bytes_sent": "%b",
    "protocol": "%H",
    "query": "%q",
    "http_x_forwarded_for": "%{X-Forwarded-For}i",
    "user_agent": "%{User-Agent}i",
    "commit_millis": "%F",
    "process_millis":
    "%D",
    "thread_name": "%I"
}"

Example server.xml file:

...
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  prefix="localhost_access_log" suffix=".json"
  pattern="{
  &quot;remote_host&quot;: &quot;%h&quot;,
  &quot;timestamp&quot;: &quot;%t&quot;,
  &quot;remote_user&quot;: &quot;%u&quot;,
  &quot;user_session_id&quot;: &quot;%S&quot;,
  &quot;method&quot;: &quot;%m&quot;,
  &quot;path&quot;: &quot;%U&quot;,
  &quot;status&quot;: &quot;%s&quot;,
  &quot;bytes_sent&quot;: &quot;%b&quot;,
  &quot;protocol&quot;: &quot;%H&quot;,
  &quot;query&quot;: &quot;%q&quot;,
  &quot;http_x_forwarded_for&quot;: &quot;%{X-Forwarded-For}i&quot;,
  &quot;user_agent&quot;: &quot;%{User-Agent}i&quot;,
  &quot;commit_millis&quot;: &quot;%F&quot;,
  &quot;process_millis&quot;:
  &quot;%D&quot;,
  &quot;thread_name&quot;: &quot;%I&quot;
  }" />
...

Advanced

For more information on the advanced configuration capabilities, see our detailed plugin guide here.