我只是想关闭日志记录。我在文档中找到了这个: https://docs.jboss.org/optaplanner/release/6.2.0.Final/optaplanner-docs/html_single/index.html#logging
但是,我的项目没有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文件在我的类路径中:
这些是日志消息:
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 (gc.Vertex@36bc2602 => 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 (gc.Vertex@265753b0 => 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 (gc.Vertex@70dc77a8 => 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 (gc.Vertex@47f128ad => 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 (gc.Vertex@2abbb9f2 => 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 (gc.Vertex@2db68692 => 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 (gc.Vertex@fa3582a => 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 (gc.Vertex@56f3b98c => 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 (gc.Vertex@7e25a483 => 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 (gc.Vertex@330d8014 => 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 (gc.Vertex@c911382 => 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 (gc.Vertex@7349c1f6 => 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 (gc.Vertex@2aab8eb6 => 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 (gc.Vertex@7d19367b => 137).
答案 0 :(得分:1)
查看类路径以查看您使用的日志记录实现。取决于你在那里找到的东西:
如果您只是看到slf4j-api,那么您可能想要添加一个slf4j-noop或其他东西。如果您看到slf4j-over-X,那么您将要将X配置为仅记录级别WARN。
答案 1 :(得分:1)
我现在通过在我的代码中添加以下两行来解决问题:
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
loggerContext.stop();