问题描述
我正在将Travis CI与我的github repo(java项目)一起使用.我的测试之一是使用SPARQL和Jena从Dbpedia获取数据.这导致许多记录被打印到Travis输出的日志中,因此Travis失败.
I'm using Travis CI with my github repo(java project). One of my tests gets data from Dbpedia using SPARQL and Jena. It causes many records i get to be printed in the log into Travis output and thus Travis fails.
例如一个日志示例:
14:52:58.756 [main] DEBUG org.apache.http.wire - http-outgoing-1 << " {
"pname": { "type": "literal", "xml:lang": "en", "value": "Yuen Poovarawan"
}[0x9], "photo": { "type": "uri", "value": "http://commons.wikimedia.org
/wiki/Special:FilePath/Yuen_Poovarawan.jpg?width=300" }[0x9], "birth": {
"type": "uri", "value": "http://dbpedia.org/resource/Thailand" }[0x9],
"bDate": { "type": "typed-literal", "datatype": "http://www.w3.org
/2001/XMLSchema#date", "value": "1950-11-05" }[0x9], "bExp": { "type":
"uri", "value": "http://dbpedia.org/resource/Thailand" }},[\n]"
所有这些日志均以[main] DEBUG org.apache.http.wire
开头.我如何禁用它们,以便Travis通过?我发现了如何使用scala/logback.xml禁用它但是log.xml是为控制台定义的.我需要帮助才能正确使用它,能否请您帮助/指导我?
All of these logs start with [main] DEBUG org.apache.http.wire
. How can i disable them so Travis passes?I've found how to disable it using scala/logback.xml but the log.xml is defined for console. I need help to use it right, can you please help/guide me?
推荐答案
使用以下内容创建logback.xml:
Create a logback.xml with below contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<logger name="org.apache" level="ERROR" />
<logger name="httpclient" level="ERROR" />
</configuration>
然后将这个logback.xml放在您的Java源目录中,以便将其包含在jar文件中.否则,从logback.xml创建一个jar并将其放到您获取所有jar的lib中.
Then put this logback.xml in your java source dir so it will be included in jar file. Otherwise create a jar from logback.xml and put this jar to your lib where you fetch all your jars.
从logback.xml创建logback.jar的简单方法是使用ant.使用以下代码创建build.xml:
A simple way to create logback.jar from logback.xml is using ant.Create build.xml with below code:
<?xml version='1.0'?>
<project name="test" default="compile" basedir=".">
<target name = "build-jar">
<jar destfile = "op/logback.jar"
basedir = "in">
<manifest>
<attribute name = "Main-Class" value = "com.tutorialspoint.util.FaxUtil"/>
</manifest>
</jar>
</target>
</project>
创建如下目录结构:
|-build.xml
|-- build.xml
|-在-> logback.xml中
|-- in --> logback.xml
|-op-> logback.jar//将在执行ant命令后生成
|-- op --> logback.jar //This will be generated after execution of ant command
现在使用ant build-jar进行编译您将拥有logback.jar.将此罐子与所有其他罐子放在一起,它将删除org.apache.http.wire调试日志
Now compile using ant build-jarYou will have logback.jar. Put this jar with all other jars and it will remove org.apache.http.wire DEBUG log
这篇关于禁用apache.http.wire调试日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!