Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.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
Scala http4s中InternalServerError请求的日志url_Scala_Http4s - Fatal编程技术网

Scala http4s中InternalServerError请求的日志url

Scala http4s中InternalServerError请求的日志url,scala,http4s,Scala,Http4s,如果发生未处理的错误,http4s将返回InternalServerError。 当InternalServerError发生时,是否可以记录请求的url? 如果是的话,最好的方法是什么?它不是开箱即用吗 下面是《快速入门指南》中g8模板项目的日志 添加了引发运行时异常的路由: [ioapp-compute-1] INFO o.h.s.m.Logger - HTTP/1.1 GET /bad_joke Headers(Accept: */*, Cache-Control: no-cache,

如果发生未处理的错误,http4s将返回InternalServerError。 当InternalServerError发生时,是否可以记录请求的url?
如果是的话,最好的方法是什么?

它不是开箱即用吗

下面是《快速入门指南》中g8模板项目的日志 添加了引发运行时异常的路由:

[ioapp-compute-1] INFO  o.h.s.m.Logger - HTTP/1.1 GET /bad_joke Headers(Accept: */*, Cache-Control: no-cache, Host: localhost:8089, Connection: Keep-Alive, User-Agent: Apache-HttpClient/4.5.12 (Java/11.0.8), Accept-Encoding: gzip,deflate) body="" 
[ioapp-compute-1] INFO  o.h.s.m.Logger - service raised an error: class java.lang.RuntimeException 
[ioapp-compute-1] ERROR o.h.s.service-errors - Error servicing request: GET /bad_joke from 127.0.0.1 
java.lang.RuntimeException: haha
        at pack.H4sRoutes$$anonfun$jokeRoutes$1.applyOrElse(H4sRoutes.scala:19)
        at pack.H4sRoutes$$anonfun$jokeRoutes$1.applyOrElse(H4sRoutes.scala:13)
        at $anonfun$combineK$1 @ org.http4s.syntax.KleisliResponseOps.$anonfun$orNotFound$1(KleisliSyntax.scala:38)
        at getOrElse @ org.http4s.syntax.KleisliResponseOps.$anonfun$orNotFound$1(KleisliSyntax.scala:38)
        at guaranteeCase$extension @ org.http4s.server.middleware.RequestLogger$.$anonfun$impl$9(RequestLogger.scala:97)
        at map @ org.http4s.server.middleware.RequestLogger$.$anonfun$impl$9(RequestLogger.scala:101)
        at flatMap @ org.http4s.server.middleware.RequestLogger$.$anonfun$impl$7(RequestLogger.scala:82)
        at flatMap @ org.http4s.server.middleware.ResponseLogger$.$anonfun$impl$7(ResponseLogger.scala:65)
        at guaranteeCase$extension @ org.http4s.server.middleware.ResponseLogger$.$anonfun$impl$7(ResponseLogger.scala:88)
        at main$ @ pack.Main$.main(Main.scala:5)