Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Exception Dropwizard请求日志_Exception_Logging_Dropwizard - Fatal编程技术网

Exception Dropwizard请求日志

Exception Dropwizard请求日志,exception,logging,dropwizard,Exception,Logging,Dropwizard,集成测试Dropwizard 0.9.2服务时出现了一个奇怪的异常。异常和配置如下所示 我不明白为什么requestLog是未知的?也就是说,下面的配置部分应该可以工作。可以在中找到requestLog io.dropwizard.server.AbstractServerFactory.class 及 io.dropwizard.server.DefaultServerFactory.class 扩展它,因此应该可以使用requestLog。这里怎么了 有人已经知道这个问题了 配置部分 ser

集成测试Dropwizard 0.9.2服务时出现了一个奇怪的异常。异常和配置如下所示

我不明白为什么requestLog是未知的?也就是说,下面的配置部分应该可以工作。可以在中找到requestLog

io.dropwizard.server.AbstractServerFactory.class

io.dropwizard.server.DefaultServerFactory.class

扩展它,因此应该可以使用requestLog。这里怎么了

有人已经知道这个问题了

配置部分

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: .....

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

我在更新版本的jackson中也出现了同样的错误,当时我添加了一个依赖项,该依赖项拉入了
com.fasterxml.jackson.core:jackson-databind:jar:2.7.2

从pom.xml中的依赖项中排除
jackson-databind
可以解决此问题。

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

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

你能把你用来测试的代码也贴出来吗?这对我很有用。我猜你使用的版本有问题。也许您在类路径中有一个较旧版本的DW?它正在工作,但是如果我使用集成测试TestRule,它就会失败。如果我创建并运行jar,也会发生这种情况。有什么办法解决这个问题吗?服务器工厂类是否未加载或加载错误?如何检查此问题?将服务器类型设置为默认值可以解决此问题,但现在我在启动期间遇到一些验证异常…也适用于从2.7.0升级到2.7.3的情况