本文介绍了Dropwizard RequestLog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在集成测试我的Dropwizard 0.9.2服务时,我有一个奇怪的异常.异常和配置如下.

I have an strange exception while integration testing my Dropwizard 0.9.2 service. The exception and configuration are below.

我不明白为什么requestLog未知? DW文档说,在配置部分下面应该管用.您可以在

I dont understand why requestLog is unknown? The DW documentation say, that below configuration part should work. The requestLog can be found in

对其进行了扩展,因此应该可以使用requestLog.怎么了?

extends it, so it should be possible to use the requestLog. Whats wrong here?

有人已经知道这个问题了吗?

Someone knows this problem already?

配置部分

server:
  requestLog:
    timeZone: UTC
    appenders:
     - type: console
       threshold: DEBUG
     - type: file
       currentLogFilename: ./log/access.log
       threshold: ALL
       archive: true
       archivedLogFilenamePattern: ./log/access.%d.log.gz
       archivedFileCount: 14
  maxThreads: 1024
  minThreads: 8
  maxQueuedRequests: 1024
  applicationConnectors:
    - type: http
      port: 80
  adminConnectors:
    - type: http
      port: 12345

例外

java.lang.RuntimeException: io.dropwizard.configuration.ConfigurationParsingException: myService.yml has an error:
  * Unrecognized field at: server.requestLog
    Did you mean?:
      - adminConnectors
      - adminContextPath
      - adminMaxThreads
      - adminMinThreads
      - applicationConnectors
        [1 more]

    at com.google.common.base.Throwables.propagate(Throwables.java:160)
    at io.dropwizard.testing.DropwizardTestSupport.startIfRequired(DropwizardTestSupport.java:214)
    at io.dropwizard.testing.DropwizardTestSupport.before(DropwizardTestSupport.java:115)
    at io.dropwizard.testing.junit.DropwizardAppRule.before(DropwizardAppRule.java:87)
    at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: io.dropwizard.configuration.ConfigurationParsingException: myservice.yml has an error:
  * Unrecognized field at: server.requestLog
    Did you mean?:
      - adminConnectors
      - adminContextPath
      - adminMaxThreads
      - adminMinThreads
      - applicationConnectors
        [1 more]

    at io.dropwizard.configuration.ConfigurationParsingException$Builder.build(ConfigurationParsingException.java:271)
    at io.dropwizard.configuration.ConfigurationFactory.build(ConfigurationFactory.java:163)
    at io.dropwizard.configuration.ConfigurationFactory.build(ConfigurationFactory.java:95)
    at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:115)
    at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:64)
    at io.dropwizard.testing.DropwizardTestSupport.startIfRequired(DropwizardTestSupport.java:212)
    ... 11 more
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "requestLog" (class io.dropwizard.server.DefaultServerFactory), not marked as ignorable (6 known properties: "adminMaxThreads", "adminConnectors", "applicationConnectors", "applicationContextPath", "adminMinThreads", "adminContextPath"])
 at [Source: N/A; line: -1, column: -1] (through reference chain: .....

推荐答案

我们遇到了同样的问题.使用旧版本的Jackson是一个问题.我们从v 2.6.3升级到v 2.6.5,错误消失了.

we had the same issue. It was a problem of using an older version of Jackson. We'Ve upgraded from v 2.6.3 to v 2.6.5 and the error was gone.

这篇关于Dropwizard RequestLog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 23:31