2015-03-19 115 views
0

我只想關閉日誌記錄。我發現這在文檔中: https://docs.jboss.org/optaplanner/release/6.2.0.Final/optaplanner-docs/html_single/index.html#logging如何關閉optaplanner中的日誌?

但是,我的項目沒有一個logback.xml文件。

有什麼建議嗎?

編輯:

我現在已經添加了以下logback.xml文件到我的類路徑的根目錄:

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

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> 
    <!-- encoders are assigned the type 
     ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> 
    <encoder> 
     <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> 
    </encoder> 
    </appender> 

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

這些JAR文件都是我的類路徑中:

  • antlr-runtime-3.5.jar
  • commons-codec-1.4.jar
  • 公地IO-2.1.jar
  • 公地郎2.6.jar
  • 公地math3-3.2.jar
  • 的dom4j-1.6.1.jar
  • 滴料,編譯器6.2.0。 Final.jar
  • Drools的核心 - 6.2.0.Final.jar
  • 滴料-decisiontables-6.2.0.Final.jar
  • 滴料的模板,6.2.0.Final.jar
  • ecj- 4.3.1.jar
  • 的freemarker-2.3.19.jar
  • 番石榴13.0.1.jar
  • jacop-4.2.0.jar
  • jcommon-1.0.23.jar
  • jfreechart的-1.0.19.jar
  • jgrapht核-0.9.1-SNAPSHOT.jar
  • 紀伊-API-6.2.0.Final.jar
  • 紀伊內部-6.2.0.Final.jar
  • 的logback經典-1.0。 9.jar
  • logba CK-核心1.0.9.jar
  • mvel2-2.2.4.Final.jar
  • optaplanner - 基準 - 6.2.0.Final.jar
  • optaplanner核心,6.2.0.Final.jar
  • POI-3.10.1.jar
  • POI-OOXML-3.10.1.jar
  • POI-OOXML-架構 - 3.10.1.jar
  • 的protobuf-java的2.5.0.jar
  • slf4j-api-1.7.2.jar
  • stax-api-1.0.1.jar
  • XML的API-1.3.04.jar
  • 的xmlbeans-2.3.0.jar
  • xmlpull-1.1.3.1.jar
  • xpp3_min-1.1.4c。罐子
  • 的XStream-1.4.7.jar

這些日誌消息:

12:33:09.729 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (47), time spent (4230), score (-452), new best score (-452), accepted/selected move count (1000/1043), picked move ([email protected] => 170). 
12:33:09.808 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (48), time spent (4309), score (-447), new best score (-447), accepted/selected move count (1000/1035), picked move ([email protected] => 169). 
12:33:09.887 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (49), time spent (4388), score (-442), new best score (-442), accepted/selected move count (1000/1042), picked move ([email protected] => 169). 
12:33:09.968 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (50), time spent (4469), score (-437), new best score (-437), accepted/selected move count (1000/1052), picked move ([email protected] => 106). 
12:33:10.048 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (51), time spent (4549), score (-432), new best score (-432), accepted/selected move count (1000/1045), picked move ([email protected] => 229). 
12:33:10.127 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (52), time spent (4628), score (-427), new best score (-427), accepted/selected move count (1000/1034), picked move ([email protected] => 234). 
12:33:10.208 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (53), time spent (4709), score (-422), new best score (-422), accepted/selected move count (1000/1054), picked move ([email protected] => 129). 
12:33:10.286 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (54), time spent (4787), score (-417), new best score (-417), accepted/selected move count (1000/1046), picked move ([email protected] => 137). 
12:33:10.365 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (55), time spent (4866), score (-412), new best score (-412), accepted/selected move count (1000/1044), picked move ([email protected] => 170). 
12:33:10.441 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (56), time spent (4942), score (-407), new best score (-407), accepted/selected move count (1000/1042), picked move ([email protected] => 127). 
12:33:10.519 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (57), time spent (5020), score (-402), new best score (-402), accepted/selected move count (1000/1048), picked move ([email protected] => 195). 
12:33:10.598 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (58), time spent (5099), score (-397), new best score (-397), accepted/selected move count (1000/1036), picked move ([email protected] => 189). 
12:33:10.677 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (59), time spent (5178), score (-392), new best score (-392), accepted/selected move count (1000/1055), picked move ([email protected] => 234). 
12:33:10.755 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -  LS step (60), time spent (5256), score (-389), new best score (-389), accepted/selected move count (1000/1049), picked move ([email protected] => 137). 
+0

很奇怪,你已經沒有實際做的事情爲它記錄。檢查您是否對optaplanner示例有依賴關係。你不應該有(只optaplanner核心和optaplanner基準) – 2015-03-19 10:58:16

回答

1

看着你的類路徑,看看你用什麼日誌實現。根據您發現有什麼:

  • 的logback-classic.jar:添加logback.xml並設置一切日誌級別WARN
  • log4j.jar:添加的log4j.xml(或屬性)並設置就緒以日誌級別警告

如果你只是看到slf4j-api,那麼你可能會想要添加一個slf4j-noop或其他東西。如果您看到slf4j-over-X,那麼您將需要將X配置爲僅記錄級別WARN。

+0

在我的類路徑是slf4j-api-1.7.2.jar,logback-classic-1.0.9.jar,logback-core-1.0.9.jar 。如果我刪除其中一個,我會得到一個異常。我應該在哪裏放置logback.xml? – twa 2015-03-19 11:13:13

+0

位於類路徑的根目錄中。檢查optaplanner-examples.jar是否不在你的類路徑中,因爲它在類路徑的根目錄中也有一個logback.xml。 – 2015-03-19 11:27:20

+0

請參閱已編輯的帖子。然而,我得到了相同的日誌消息... – twa 2015-03-19 11:38:21

1

現在我已經加入下面的兩行我的代碼解決了這個問題:

LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); 
loggerContext.stop(); 
+0

這是一個骯髒的黑客:)我想知道你的classpath中的哪個jar配置logback:其中一個必須有該logback.xml文件(如果它不是你的項目本身在src /主/資源) – 2015-03-19 16:29:21

相關問題