2015-02-10 80 views
1

我想讓我的日誌顯示在我的遊戲控制檯中。這裏是一個控制器我試圖記錄從信息的例子:日誌沒有顯示Scala Play 2.3.x

import play.api.Logger 
object LandingPage extends Controller { 
    import ComponentRegistry._ 
    private val emailForm = 
    Form(mapping("id" -> optional(of[Long]), "emailAddress" -> email)(Email.apply _)(Email.unapply _)) 
    def index = Action { 
    Logger.info("Index method inside of LandingPage") 
    Ok("INDEX") 
    } 

    def submit = Action { implicit request => 
    Logger.info("Inside of submit method in Landing Page controller") 
    Ok("SUBMIT PAGE") 

    } 
} 

這裏是我在我的application.conf

#Logger provided to your application: 
logger.application=INFO 

什麼我需要修改以獲得輸出中的顯示我的控制檯從日誌?

編輯:這可能是有用的信息。顯然我有多個slf4j綁定

SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/home/chris/dev/suredbits-web/lib/suredbits-core-assembly-1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/home/chris/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 

不知道如何擺脫這些多個綁定。

也是我build.sbt

name := "suredbits-web" 

version := "0.0" 

lazy val root = (project in file(".")).enablePlugins(play.PlayScala, SbtWeb) 

scalaVersion := "2.11.4" 

organization := "com.suredbits.web" 

libraryDependencies ++= { 
    val sprayV = "1.3.2" 
    val akkaV = "2.3.8" 
    val bootstrapV = "3.3.2" 
    val webJarsPlayV = "2.3.0" 
    Seq(
     "io.spray"   %% "spray-can"  % sprayV withSources() withJavadoc(), 
    "io.spray"   %% "spray-routing" % sprayV withSources() withJavadoc(), 
    "io.spray"   %% "spray-testkit" % sprayV % "test" withSources() withJavadoc(), 
    "com.typesafe.akka" %% "akka-actor" % akkaV withSources() withJavadoc(), 
    "com.typesafe.akka" %% "akka-testkit" % akkaV % "test" withSources() withJavadoc(), 
    "org.specs2"   %% "specs2-core" % "2.4.7-scalaz-7.0.6" % "test" withSources() withJavadoc(), 
     "org.scalactic"    %% "scalactic"  % "2.2.1" % "test" withSources() withJavadoc(), 
     "io.spray"   %% "spray-json" % "1.3.0" withSources() withJavadoc(), 
     "com.github.nscala-time" %% "nscala-time" % "1.6.0" withSources() withJavadoc() , 
    "com.novocode"  % "junit-interface" % "0.10" % "test" withSources() withJavadoc(), 
     "org.webjars"   %% "webjars-play" % webJarsPlayV withSources() withJavadoc(), 
     "org.webjars"   % "bootstrap"  % bootstrapV withSources() withJavadoc(), 
     "org.webjars"   % "font-awesome" % "4.3.0-1", 
     "org.webjars"   % "jquery"   % "2.1.3", 
     "com.typesafe.slick" %% "slick"   % "2.1.0" withSources() withJavadoc(), 
    "com.typesafe.slick" %% "slick-testkit" % "2.1.0" % "test" withSources() withJavadoc(), 
     "org.postgresql"  % "postgresql"  % "9.3-1100-jdbc41" withSources() withJavadoc(), 
    "org.scalatestplus" %% "play" % "1.2.0" % "test" withSources() withJavadoc() 
) 
} 

testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s", "-a") 

parallelExecution in Test := false 

scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature") 

includeFilter in (Assets, LessKeys.less) := "*.less" 

回答

1

的播放應用程序的日誌級別已經是INFO默認。

無日誌輸出的原因可能與您的多個SLF4J綁定有關。

Play默認使用logback。顯然你在你的suredbits-core-assembly項目中包含了一個(不同的?)SLF4J綁定。

Play配置logback記錄器,但可能不是您正在使用的綁定的記錄器。即使包含了兩次logback,也可能因爲不同的類加載器而無法配置SLF4J最終使用的記錄器。

你不應該定義任何SLF4J綁定爲核心項目的相關性:僅

http://www.slf4j.org/manual.html#libraries

嵌入式組件,如庫或框架不應申報任何SLF4J的依賴性結合,但依靠SLF4J的API。當庫聲明對特定綁定的傳遞依賴關係時,該綁定強加給最終用戶否定SLF4J的目的。請注意,聲明綁定的非傳遞依賴性(例如用於測試)不會影響最終用戶。

因此,刪除核心項目中對SLF4J綁定的依賴關係,或者至少在組裝jar時排除org.slf4j.impl包。

0

我認爲你必須設置爲根記錄器級別:

logger.root=INFO 
+0

這沒有奏效,我向OP中添加了更多信息。 – 2015-02-10 18:34:56

相關問題