Travis 最大日志大小并省略库生成的日志

Travis max log size & omitting library generated log

我正在使用 Github (https://github.com/connecta-solutions/connecta-framework) and Travis (https://travis-ci.org/connecta-solutions/connecta-framework) 来托管和构建我的 open-source 项目,该项目使用 Apache Metamodel 作为其依赖项之一。

我没有进行很多单元测试,但是使用 Metamodel 中的功能的特定测试生成的日志是巨大的,并且超过了 Travis 确定的 4MB 日志大小,因此它退出构建并显示以下消息:

The log length has exceeded the limit of 4 MB (this usually means that the test suite is raising the same exception over and over).

The job has been terminated

我得到的大部分日志都是来自元模型内部比较器的不重要的调试消息,通常会提供以下输出:

18:18:23.519 [main] DEBUG o.a.metamodel.util.ObjectComparator - compare(Sul,50)
18:18:23.519 [main] INFO  o.a.metamodel.util.ObjectComparator - Using ToStringComparator because no apparent better comparison method could be found
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - SUM(csv_cities.csv.vendas).hashCode()
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is null, returning constant
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is null, returning constant
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is a regular object, returning hashCode
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is a regular object, returning hashCode
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is a regular object, returning hashCode
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is null, returning constant
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is null, returning constant
18:18:23.519 [main] DEBUG o.a.metamodel.util.EqualsBuilder - append(false)
18:18:23.519 [main] DEBUG o.a.metamodel.util.EqualsBuilder - append(true)
18:18:23.519 [main] DEBUG o.a.metamodel.util.ObjectComparator - compare(Sul,50)
18:18:23.519 [main] INFO  o.a.metamodel.util.ObjectComparator - Using ToStringComparator because no apparent better comparison method could be found
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - SUM(csv_cities.csv.vendas).hashCode()
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is null, returning constant
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is null, returning constant
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is a regular object, returning hashCode
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is a regular object, returning hashCode
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is a regular object, returning hashCode
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is null, returning constant
18:18:23.519 [main] DEBUG org.apache.metamodel.util.BaseObject - obj is null, returning constant
18:18:23.519 [main] DEBUG o.a.metamodel.util.EqualsBuilder - append(false)
18:18:23.519 [main] DEBUG o.a.metamodel.util.EqualsBuilder - append(true)

理想的情况是 Travis 以某种方式接受了这一点,因为当您遇到问题时,不重要的日志很快就会变得重要。无论如何,我试图降低日志级别以仅获取警告和错误,为 log4j 传递参数来这样做,如下所示:

mvn test -Dorg.slf4j.simpleLogger.defaultLogLevel=warn

后来我意识到Logback是这个Metamodel特性的日志引擎,我发现不可能像Log4j中那样用一个参数来降低Logback的日志级别。但是我没有找到一种方法来删除 logback 并使用我在整个应用程序中使用的标准记录器,然后我可以控制它尝试输出消息的级别。

这是 Travis CI 的遗言吗?有没有办法保留所有日志,即使超过 4MB 日志大小?

如果没有,我怎样才能只删除 Metamodel 中日志中这个不重要的部分?

将整个日志保留在开发模式下,并在 Travis 构建中将其省略将是完美的,但如果我做不到,我可以永远省略日志的这一部分,如果别无选择。

尝试通过放置在项目 src/test/resources 中的 log4j.xml 配置文件来调整特定命名空间(例如整个 org.apache.metamodel)的日志记录。

可以在元模型代码库中找到示例:https://github.com/apache/metamodel/blob/060884c17d1c5c35348d2cb675bed1c404013579/jdbc/src/test/resources/log4j.xml#L12