2015-03-19 114 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

相关问题