如何使用 Scala 登录 Play Framework?

How can I log in Play Framework using Scala?

我已将 Play Framework 更新至 2.7,但收到以下警告:

method info in object Logger is deprecated (since 2.7.0): Create an instance of via Logger(...) and use the same-named method. Or use SLF4J directly.

所以我的问题是:

P.S.:

在不基于 Play Framework 的项目中,我曾经使用 scala-logging 它是 SLF4J 的包装器。这可以解决吗?

Play 2.7 为 Scala 提供了类似于 scala-logging 的特性。它会创建一个 val,您可以在 class/object:

中使用它
import play.api.Logging

class MyClass extends Logging {
  // `logger` is automaticaly defined by the `Logging` trait:
  logger.info("hello!")
}

所以还有一种登录方式现在就玩。