8.3. 更改 OptaPlanner 解析器日志记录级别


您可以更改 OptaPlanner solver 中的日志级别,以查看解析器活动。以下列表描述了不同的日志记录级别:

  • 错误 :日志错误,但那些作为 RuntimeException 抛出到调用代码的除外。

    如果发生错误,OptaPlanner 通常会快速失败。它将抛出一个 RuntimeException 的子类,并将详细信息放到调用代码。为避免重复的日志消息,它不会将其记录为错误。除非调用代码明确捕获并消除 RuntimeException,否则 线程的默认 'ExceptionHandler 会将它记录为错误。同时,代码被破坏导致进一步的损害或模糊处理错误。

  • 警告 :日志可疑的情况
  • info :记录每个阶段和解析器本身
  • Debug :记录每个阶段的每个步骤
  • trace :记录每个阶段的每个步骤的每次移动
注意

指定 trace 日志记录会大大降低性能。但是,在开发过程中,追踪 日志记录非常有用,以发现瓶颈。

即使 调试日志记录 对于快速步骤算法(如 Late Acceptance 和 Simulated Annealing)的性能要下降,但不适用于降低步骤算法,如 Tabu Search。

trace 和 debug 日志记录都会导致多线程与大多数附加者的拥塞。

在 Eclipse 中,调试 到控制台的日志记录往往会因为分数计算速度超过 10000 每秒造成拥塞。IntelliJ 或 Maven 命令行都不受此问题的影响。

流程

将日志记录级别设置为 debug 日志记录,以查看阶段何时结束以及执行快速步骤。

以下示例显示了 debug 日志记录的输出:

INFO  Solving started: time spent (3), best score (-4init/0), random (JDK with seed 0).
DEBUG     CH step (0), time spent (5), score (-3init/0), selected move count (1), picked move (Queen-2 {null -> Row-0}).
DEBUG     CH step (1), time spent (7), score (-2init/0), selected move count (3), picked move (Queen-1 {null -> Row-2}).
DEBUG     CH step (2), time spent (10), score (-1init/0), selected move count (4), picked move (Queen-3 {null -> Row-3}).
DEBUG     CH step (3), time spent (12), score (-1), selected move count (4), picked move (Queen-0 {null -> Row-1}).
INFO  Construction Heuristic phase (0) ended: time spent (12), best score (-1), score calculation speed (9000/sec), step total (4).
DEBUG     LS step (0), time spent (19), score (-1),     best score (-1), accepted/selected move count (12/12), picked move (Queen-1 {Row-2 -> Row-3}).
DEBUG     LS step (1), time spent (24), score (0), new best score (0), accepted/selected move count (9/12), picked move (Queen-3 {Row-3 -> Row-2}).
INFO  Local Search phase (1) ended: time spent (24), best score (0), score calculation speed (4000/sec), step total (2).
INFO  Solving ended: time spent (24), best score (0), score calculation speed (7000/sec), phase total (2), environment mode (REPRODUCIBLE).

所有花费的时间都以毫秒为单位。

所有都记录到 SLF4J,这是一个一个简单的日志记录信息,它将每个日志消息委派给 Logback、Apache Commons Logging、Log4j 或 java.util.logging。为您选择的日志记录框架添加依赖项。

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.