Code Monkey home page Code Monkey logo

springboot-logback-logstash-demo's Introduction

springboot-logback-logstash-demo

Collect Access Log and Running Log, Support SpringBoot 2.x
使用logback收集springboot应用的运行日志和访问日志,并输出到logstash中

logstash

下载安装Logstash

官网下载安装: Logstash

使用配置文件启动,logstash.conf:

input {
  tcp {
    port => 4560
    codec => json
  }
}
output {
  stdout {
    codec => rubydebug
  }
}

要求

  • jdk 11+
  • gradle 6+

logstash输出结果部分展示

{
        "httpStatus" => "200",
    "requestMapping" => "/foo/bar",
     "requestParams" => "{\"name\":\"test\",\"age\":18}",
              "type" => "AccessLog",
       "requestHost" => "localhost:52271",
              "port" => 52267,
        "requestURI" => "/foo/bar",
          "@version" => "1",
     "executionTime" => "140",
                "ip" => "127.0.0.1",
        "createTime" => "2020-09-29 11:47:08",
              "host" => "localhost",
        "@timestamp" => 2020-09-29T03:47:08.820Z,
               "pid" => "42358",
        "httpMethod" => "POST"
}
{
         "level" => "INFO",
          "type" => "RunningLog",
          "port" => 52254,
      "@version" => "1",
        "thread" => "http-nio-auto-1-exec-3",
    "createTime" => "2020-09-29 11:47:08",
          "host" => "localhost",
    "@timestamp" => 2020-09-29T03:47:08.818Z,
           "pid" => "42358",
       "message" => "add person Person{name='test', age=18}",
        "logger" => "com.snaildrum.demo.DemoApplication"
}
{
         "level" => "INFO",
          "type" => "RunningLog",
          "port" => 52254,
      "@version" => "1",
        "thread" => "http-nio-auto-1-exec-4",
    "createTime" => "2020-09-29 11:47:08",
          "host" => "localhost",
    "@timestamp" => 2020-09-29T03:47:08.861Z,
           "pid" => "42358",
       "message" => "query person zhangsan",
        "logger" => "com.snaildrum.demo.DemoApplication"
}
{
        "httpStatus" => "200",
    "requestMapping" => "/foo/person/{name}",
              "type" => "AccessLog",
       "requestHost" => "localhost:52271",
              "port" => 52267,
        "requestURI" => "/foo/person/zhangsan",
          "@version" => "1",
     "executionTime" => "46",
                "ip" => "127.0.0.1",
        "createTime" => "2020-09-29 11:47:08",
              "host" => "localhost",
        "@timestamp" => 2020-09-29T03:47:08.891Z,
               "pid" => "42358",
        "httpMethod" => "GET"
}


参考

springboot-logback-logstash-demo's People

Contributors

snail-drum avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.