问题:
解决:
- 下载文件 docker-compose.yaml 见下边
- 执行 cd <dir>
- docker-compose up -d
- log4j.properties 见下边,然后用 log4j (1.x) 写点东西
- 访问kibana http://localhost:5601 查看 ELK 效果
在win10 docker 17 -ce / docker-compose 1.16 上上测试通过
docker-compose.yaml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
version: "3" services: es: image: elasticsearch:2.3 networks: - elknet logstash: image: logstash:2.3 entrypoint: - logstash - -e - input { log4j { mode=>"server" host=>"0.0.0.0" port=>3456 type=>"log4j" } } output { elasticsearch { hosts=>[ "es" ] } } networks: - elknet ports: - "3456:3456" depends_on: - es - kibana kibana: image: kibana:4.5 environment: ELASTICSEARCH_URL: http://es:9200 networks: - elknet ports: - "5601:5601" depends_on: - es networks: elknet: |
log4j.properties:
|
log4j.rootLogger = DEBUG,console,tcp log4j.appender.console = org.apache.log4j.ConsoleAppender log4j.appender.console.layout = org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n log4j.appender.tcp=org.apache.log4j.net.SocketAppender log4j.appender.tcp.Port=3456 log4j.appender.tcp.RemoteHost=localhost log4j.appender.tcp.ReconnectionDelay=10000 log4j.appender.tcp.Application=ssmm |
参考: