How to read tomcat logs using logstash

I am trying to configure logstash. In the wiki I found, we can read apache or other system logs. What is the configuration and steps for reading tomcat logs.

+5
source share
3 answers

Tomcat uses Java-Util-Logging.

You can use the direct GELF application to send logs from Tomcat to logstash.

You need to make some changes to your run - script and log configuration (and two banks):

/conf/logging.properties

handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler, biz.paluch.logging.gelf.jul.GelfLogHandler

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler, biz.paluch.logging.gelf.jul.GelfLogHandler


biz.paluch.logging.gelf.jul.GelfLogHandler.host=udp:localhost
biz.paluch.logging.gelf.jul.GelfLogHandler.port=12201
biz.paluch.logging.gelf.jul.GelfLogHandler.level=INFO

/bin/catalina.sh

if [ -r "$CATALINA_BASE/bin/logstash-gelf-1.4.2.jar" ] ; then
  CLASSPATH=$CLASSPATH:$CATALINA_BASE/bin/logstash-gelf-1.4.2.jar:$CATALINA_BASE/bin/json-simple-1.1.jar:$CATALINA_BASE/bin/jedis-2.5.1.jar:$CATALINA_BASE/bin/commons-pool2-2.0.jar
fi

logstash-gelf : logstash-gelf-1.5.2-logging-module.zip

See also Changes for logstash-gelf with Tomcat

+2
source

, , Java , .

logstash docs log4j: http://logstash.net/docs/1.1.9/inputs/log4j

input {
  log4j {
    add_field => ... # hash (optional), default: {}
    charset => ... # string, one of ["ASCII-8BIT", "UTF-8", "US-ASCII", ...] (optional), default: "UTF-8"
    data_timeout => ... # number (optional), default: 5
    debug => ... # boolean (optional), default: false
    format => ... # string, one of ["plain", "json", "json_event"] (optional)
    host => ... # string (optional), default: "0.0.0.0"
    message_format => ... # string (optional)
    mode => ... # string, one of ["server", "client"] (optional), default: "server"
    port => ... # number (required)
    tags => ... # array (optional)
    type => ... # string (required)
  }
}
+1

As stated here , you can use ANY log file, no matter what source it comes from. You will need to use the input as a file and configure other things accordingly!

input {
  file {
## Your configuration goes here like file path 
## and other config, check documentation
}
}
0
source

All Articles