5

我正在尝试配置logstash。在 wiki 中,我发现我们可以阅读 apache 或其他系统日志。读取tomcat日志的配置和步骤是什么。

4

3 回答 3

2

Tomcat 使用 Java-Util-Logging。

您可以使用直接 GELF appender 将日志从 Tomcat 提交到 logstash。

您需要在启动脚本和记录器配置(和两个 jar)中进行一些更改:

/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-gelflogstash-gelf-1.5.2-logging-module.zip

另请参阅对 Tomcat 的 logstash-gelf 的更改

于 2014-08-29T12:56:07.120 回答
1

这可能取决于 Java 日志框架的选择以及日志框架的输出是如何格式化的。

logstash 文档给出了一个示例 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)
  }
}
于 2013-03-18T16:55:00.330 回答
0

如此所述,您可以使用任何日志文件,无论它来自什么来源。您必须将输入用作文件并相应地配置其他内容!

input {
  file {
## Your configuration goes here like file path 
## and other config, check documentation
}
}
于 2012-10-08T21:27:34.000 回答