我已经完成以下步骤来尝试为我的akka应用程序配置日志记录:
创建了一个application.conf文件并将其放在src/main/resources中.看起来像:
akka {
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loglevel = "INFO"
}
创建了一个logback.xml文件并将其放在src/main/resources中.看起来像:
<configuration>
<appender name="FILE" class="ch.qos.logback.core.fileappender">
<File>./logs/akka.log</File>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-5level] %msg%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="FILE" />
</root>
</configuration>
Run Code Online (Sandbox Code Playgroud)将以下内容添加到我的.scala sbt构建文件中:
libraryDependencies += "com.typesafe.akka" % "akka-slf4j" % "2.0.3",
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.0.9"
lazy val logback = "ch.qos.logback" % "logback-classic" % "1.0.9"
尝试此代码记录:
import akka.event.Logging
val log = Logging(context.system, this)
log.info("...")
我得到的只是标准输出日志记录,没有日志创建日志文件.
我错过了一步吗?或者配置错误?
我正在尝试使用Play 2.0 websockets进行一个非常简单的概念验证.
这就是我现在正在做的事情:
def wsrequest = WebSocket.using[String] { request =>
// Send a single 'Hello!' message
val out = Enumerator("Hello!")
// Just consume and ignore the input
val in = Iteratee.consume[String]()
// tie the in and out values to each other
(in, out)
}
Run Code Online (Sandbox Code Playgroud)
GET /wsrequest controllers.Application.wsrequest
Run Code Online (Sandbox Code Playgroud)
var sock = new WS("@routes.Application.wsrequest().webSocketURL()")
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试编译它时,我收到一个错误:
[info] Compiling 5 Scala sources and 1 Java source to target\scala-2.9.1\classes...
[error] target\scala-2.9.1\src_managed\main\views\html\index.template.scala:32: Cannot find any HTTP Request Header here
[error] Error occurred …Run Code Online (Sandbox Code Playgroud)