2016-01-23 61 views
0

在Slick中使用工作表時,它會記錄如此多的調試信息,以至於我看不到所做的實際結果。我一直在試圖弄清楚如何在幾個小時內禁用調試日誌,但我無法弄清楚。IntelliJ Scala工作表:減少調試日誌記錄

如何禁用(光滑)/(工作表)日誌記錄?

從工作表:

db.run(
    countries.take(5) 
     .map(_.country) 
     .result 
) 

,輸出〜200行:

countries: slick.lifted.TableQuery[Country] = Rep(TableExpansion) 
z: slick.lifted.Query[Country,Country#TableElementType,Seq] = Rep(Filter @968224334) 
res0: java.sql.Connection = [email protected] 
BEFORE 
22:17:58.192 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - Source: 
| Bind 
| from s2: Take 
|  from: TableExpansion 
|  table s3: Table country 
|  columns: ProductNode 
|   1: Path s3.id : String' 
|   2: Path s3.name : String' 
|  count: LiteralNode 5 (volatileHint=false) 
| select: Pure t4 
|  value: Path s2.name : String' 

22:17:58.193 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.AssignUniqueSymbols - Detected features: UsedFeatures(false,false,false,false) 
22:17:58.194 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - After phase assignUniqueSymbols: 
| Bind 
| from s5: Take 
|  from: TableExpansion 
|  table s6: Table country 
|  columns: ProductNode 
|   1: Path s6.id : String' 
|   2: Path s6.name : String' 
|  count: LiteralNode 5 (volatileHint=false) 
| select: Pure t8 
|  value: Path s5.name : String' 

22:17:58.195 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - After phase inferTypes: (no change) 
22:17:58.196 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.ExpandTables - Found Selects for NominalTypes: @t7 
22:17:58.197 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.ExpandTables - With correct table types: 
| Bind : Vector[t8<String'>] 
| from s5: Take : Vector[@t7<{id: String', name: String'}>] 
|  from: Table country : Vector[@t7<{id: String', name: String'}>] 
|  count: LiteralNode 5 (volatileHint=false) : Long 
| select: Pure t8 : Vector[t8<String'>] 
|  value: Path s5.name : String' 

22:17:58.197 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.ExpandTables - Table expansions: @t7 -> (s6,ProductNode) 
22:17:58.198 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - After phase expandTables: 
| Bind : Vector[t8<String'>] 
| from s5: Take : Vector[@t7<{id: String', name: String'}>] 
|  from: Table country : Vector[@t7<{id: String', name: String'}>] 
|  count: LiteralNode 5 (volatileHint=false) : Long 
| select: Pure t8 : Vector[t8<String'>] 
|  value: Path s5.name : String' 

22:17:58.199 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - After phase forceOuterBinds: 
| Bind : Vector[t8<String'>] 
| from s5: Take : Vector[@t7<{id: String', name: String'}>] 
|  from: Table country : Vector[@t7<{id: String', name: String'}>] 
|  count: LiteralNode 5 (volatileHint=false) : Long 
| select: Pure t8 : Vector[t8<String'>] 
|  value: Path s5.name : String' 

22:17:58.200 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - After phase removeMappedTypes: (no change) 
22:17:58.200 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - After phase expandSums: (no change) 
22:17:58.201 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - After phase expandRecords: 
| Bind : Vector[t8<String'>] 
| from s5: Take : Vector[@t7<{id: String', name: String'}>] 
|  from: Table country : Vector[@t7<{id: String', name: String'}>] 
|  count: LiteralNode 5 (volatileHint=false) : Long 
| select: Pure t8 : Vector[t8<String'>] 
|  value: Path s5.name : String' 

22:17:58.202 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.FlattenProjections - Flattening projection t8 
22:17:58.202 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.FlattenProjections - Analyzing s5.name with symbols 
| Path s5.name : String' 

22:17:58.203 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.FlattenProjections - Translated s5.name to: 
| Path s5.name 

22:17:58.203 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.FlattenProjections - Flattening node at Path 
| Path s5.name 

22:17:58.204 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.FlattenProjections - Adding definition: s9 -> Path s5.name 
22:17:58.204 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.FlattenProjections - Adding translation for t8: (Map(List() -> s9), UnassignedType) 
22:17:58.204 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.FlattenProjections - Flattened projection to 
| Pure t8 
| value: StructNode 
|  s9: Path s5.name 

22:17:58.205 [NGSession 241: 127.0.0.1: compile-server] DEBUG slick.compiler.QueryCompiler - After phase flattenProjections: 
| Bind : Vector[t8<{s9: String'}>] 
| from s5: Take : Vector[@t7<{id: String', name: String'}>] 
|  from: Table country : Vector[@t7<{id: String', name: String'}>] 
|  count: LiteralNode 5 (volatileHint=false) : Long 
| select: Pure t8 : Vector[t8<{s9: String'}>] 
|  value: StructNode : {s9: String'} 
|  s9: Path s5.name : String' 

(和它的推移和和...)

所以,我該怎麼辦關閉這個日誌記錄?

回答

1

假設您使用的是默認的sbt directory structure,則需要configure logback才能記錄您想要的內容。要做到這一點,添加文件src/main/resources/logback.xml有以下內容:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> 
    <encoder> 
     <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> 
    </encoder> 
    </appender> 

    <logger name="slick.lifted" level="INFO" /> 

    <root level="debug"> 
    <appender-ref ref="STDOUT" /> 
    </root> 
</configuration> 

當然,你也可以配置其他日誌級別,除了特定的華而不實的包裝INFO以及其他日誌級別。

最後,如果您使用的是Playframework目錄結構,請將logback.xml文件放入conf目錄中。