禁用akka http中的错误日志记录

时间:2017-10-25 13:09:06

标签: akka akka-stream akka-http

向我无法控制的第三方服务发出请求,我在日志中遇到以下异常:

2017-10-25 17:08:45 [main-actor-system-akka.actor.default-dispatcher-16] ERROR akka.actor.RepointableActorRef - Error in stage [akka.http.impl.engine.client.OutgoingConnectionBlueprint$PrepareResponse@7feef72e]: Illegal response status code: 920
akka.http.scaladsl.model.IllegalResponseException: Illegal response status code: 920
at akka.http.impl.engine.client.OutgoingConnectionBlueprint$PrepareResponse$$anon$1.onPush(OutgoingConnectionBlueprint.scala:191)
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:499)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:401)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:571)
at akka.stream.impl.fusing.ActorGraphInterpreter$SimpleBoundaryEvent.execute(ActorGraphInterpreter.scala:42)
at akka.stream.impl.fusing.ActorGraphInterpreter$SimpleBoundaryEvent.execute$(ActorGraphInterpreter.scala:38)
at akka.stream.impl.fusing.ActorGraphInterpreter$BatchingActorInputBoundary$OnNext.execute(ActorGraphInterpreter.scala:75)
at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:546)
at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:725)
at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:740)
at akka.actor.Actor.aroundReceive(Actor.scala:514)
at akka.actor.Actor.aroundReceive$(Actor.scala:512)
at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:650)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:527)
at akka.actor.ActorCell.invoke(ActorCell.scala:496)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
at akka.dispatch.Mailbox.run(Mailbox.scala:224)
at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

我在superPool中使用Flow

Flow[String].map(x => Get(x) -> NotUsed) // simplified: url as string
  .via(Http().superPool[NotUsed]())
  .map {
    // handle response: Success and Failure. It resumes on failure.
  }
  ...

请注意,它不会使图表崩溃,我只想删除日志消息。

我自己不在任何地方登录。

这是我的application.conf

akka {
  http {
    parsing {
      uri-parsing-mode = relaxed
      cookie-parsing-mode = raw
      illegal-header-warnings = off
      illegal-response-header-value-processing-mode = ignore
      error-logging-verbosity = off
    }
  }
}

使用akka 2.5.4,akka-http 10.0.10

1 个答案:

答案 0 :(得分:1)

我认为解决此问题的最佳方法是实际注册服务器返回的无效状态代码,文档中有一个页面描述了如何使用此处的示例执行此操作:https://doc.akka.io/docs/akka-http/10.0.10/scala/http/common/http-model.html#registering-custom-status-codes