vertx LoggerHandler not adding logback

前端 未结 3 1470
执念已碎
执念已碎 2021-01-01 01:35

I am trying to use LoggerHandler to log all incoming requests. I am using logback.xml to specify appenders. I am setting system property for logging.

System         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-01 01:41

    I know this question is getting a bit old, but the only way I was able to get the vertx LoggerHandler to not use JUL was to call LoggerFactory.initialise() after setting the system property as described in the question.

    Even better, I set the property in my build.gradle, like so:

    run {
      systemProperty(
        "vertx.logger-delegate-factory-class-name",
        "io.vertx.core.logging.SLF4JLogDelegateFactory"
      )
      args = ['run', mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$mainClassName", "--on-redeploy=$doOnChange",
              "-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory" ]
    }
    

    And then at the very top of my MainVerticle::start I have:

    LoggerFactory.initialise()
    

    And, boom. Everything is now formatted correctly, including all the startup output.

提交回复
热议问题