spray.io 调试指令
spray.io debugging directives
我正在尝试 spray.io,但我无法使喷射调试指令 logRequestResponse 工作 - 我在日志中没有看到任何输出。
val route: Route = {
pathPrefix("city") {
pathPrefix("v1") {
path("transaction" / Segment / Segment) {
(siteId: String, transactionId: String) =>
post {
authenticate(BasicAuth(UserPasswordAuthenticator _, realm = "bd cinema import api")) {
user =>
DebuggingDirectives.logRequestResponse("city-trans", Logging.InfoLevel) {
val resp = "Hello"
complete {
resp
}
}
}
}
}
}
}
}
我是不是漏掉了什么?
我是否需要在喷雾配置的某个地方启用全局调试?我尝试了不同的地方,其中 none 个按预期工作
检查您的 application.conf and logback.xml 是否具有合理的值,因为 Spray 项目中的这些示例文件
关注application.conf
akka.loglevel
=INFO
akka {
log-config-on-start = on
loglevel = "INFO"
actor.timeoutsecs = 2
loggers = ["akka.event.slf4j.Slf4jLogger"]
}
在 stdout
上显示日志的最小值 logback.xml
。
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<target>System.out</target>
<encoder>
<pattern>[%d{dd/MM/yyyy HH:mm:ss.SSS}] [%level] [%thread] %logger{36} - %msg %n</pattern>
<!--<pattern>%X{akkaTimestamp} %-5level[%thread] %logger{0} - %msg%n</pattern>-->
</encoder>
</appender>
<!-- <logger name="com.vegatic" level="DEBUG"/> -->
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
通常怀疑 logger
的 name
属性与 Scala 命名空间不匹配或不够详细,为了清楚起见,已在上面的示例中进行了评论
文档 link LoggingContext
A LoggingAdapter that can always be supplied implicitly. If an
implicit ActorSystem the created LoggingContext forwards to the log of
the system. If an implicit ActorContext is in scope the created
LoggingContext uses the context's ActorRef as a log source. Otherwise,
i.e. if neither an ActorSystem nor an ActorContext is implicitly
available, the created LoggingContext will forward to NoLogging, i.e.
"/dev/null".
我正在尝试 spray.io,但我无法使喷射调试指令 logRequestResponse 工作 - 我在日志中没有看到任何输出。
val route: Route = {
pathPrefix("city") {
pathPrefix("v1") {
path("transaction" / Segment / Segment) {
(siteId: String, transactionId: String) =>
post {
authenticate(BasicAuth(UserPasswordAuthenticator _, realm = "bd cinema import api")) {
user =>
DebuggingDirectives.logRequestResponse("city-trans", Logging.InfoLevel) {
val resp = "Hello"
complete {
resp
}
}
}
}
}
}
}
}
我是不是漏掉了什么? 我是否需要在喷雾配置的某个地方启用全局调试?我尝试了不同的地方,其中 none 个按预期工作
检查您的 application.conf and logback.xml 是否具有合理的值,因为 Spray 项目中的这些示例文件
关注application.conf
akka.loglevel
=INFO
akka {
log-config-on-start = on
loglevel = "INFO"
actor.timeoutsecs = 2
loggers = ["akka.event.slf4j.Slf4jLogger"]
}
在 stdout
上显示日志的最小值 logback.xml
。
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<target>System.out</target>
<encoder>
<pattern>[%d{dd/MM/yyyy HH:mm:ss.SSS}] [%level] [%thread] %logger{36} - %msg %n</pattern>
<!--<pattern>%X{akkaTimestamp} %-5level[%thread] %logger{0} - %msg%n</pattern>-->
</encoder>
</appender>
<!-- <logger name="com.vegatic" level="DEBUG"/> -->
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
通常怀疑 logger
的 name
属性与 Scala 命名空间不匹配或不够详细,为了清楚起见,已在上面的示例中进行了评论
文档 link LoggingContext
A LoggingAdapter that can always be supplied implicitly. If an implicit ActorSystem the created LoggingContext forwards to the log of the system. If an implicit ActorContext is in scope the created LoggingContext uses the context's ActorRef as a log source. Otherwise, i.e. if neither an ActorSystem nor an ActorContext is implicitly available, the created LoggingContext will forward to NoLogging, i.e. "/dev/null".