首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Dropwizard RequestLog

Dropwizard RequestLog
EN

Stack Overflow用户
提问于 2016-01-26 16:00:16
回答 3查看 2.3K关注 0票数 1

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

我不明白为什么requestLog是未知的?DW文档说,下面的配置部分应该可以工作。requestLog可以在

io.dropwizard.server.AbstractServerFactory.class

io.dropwizard.server.DefaultServerFactory.class

扩展它,所以应该可以使用requestLog。这里出什么问题了?

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

配置部分

代码语言:javascript
复制
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

异常

代码语言:javascript
复制
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: .....
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-02-06 21:53:53

我们也有同样的问题。这是一个问题,使用一个老版本的杰克逊。我们已经从v 2.6.3升级到v 2.6.5,并且错误消失了。

票数 2
EN

Stack Overflow用户

发布于 2019-09-17 13:09:14

尝试将timeZone: UTC放在每个附录下面,如下所示:

代码语言:javascript
复制
server:
  requestLog:
    appenders:
     - type: console
       threshold: DEBUG
       timeZone: UTC
     - type: file
       currentLogFilename: ./log/access.log
       threshold: ALL
       archive: true
       archivedLogFilenamePattern: ./log/access.%d.log.gz
       archivedFileCount: 14
       timeZone: UTC
  maxThreads: 1024
  minThreads: 8
  maxQueuedRequests: 1024
  applicationConnectors:
    - type: http
      port: 80
  adminConnectors:
    - type: http
      port: 12345
票数 1
EN

Stack Overflow用户

发布于 2017-05-17 18:36:25

对于最近版本的杰克逊,我也出现了同样的错误,当时我添加了一个引入com.fasterxml.jackson.core:jackson-databind:jar:2.7.2的依赖项

jackson-databind排除在pom.xml中的依赖项之外解决了这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35018222

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档