簡體   English   中英

如何使用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.

所以我的問題是:

  • 我是否應該創建Logger實例並將其傳遞給每個組件?

PS:

在不基於Play Framework的項目中,我曾經使用scala日志記錄 ,它是SLF4J的包裝。 這可以解決嗎?

Play 2.7為Scala提供了一個與scala記錄類似的特征。 它創建一個val ,您可以在類/對象中使用它:

import play.api.Logging

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

因此,還有另一種方法可以立即登錄Play。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM