问题
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.
A log example for instance:
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]"
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?
回答1:
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>
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.
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>
Create a directory structure like:
|-- build.xml
|-- in --> logback.xml
|-- op --> logback.jar //This will be generated after execution of ant command
Now compile using ant build-jar You will have logback.jar. Put this jar with all other jars and it will remove org.apache.http.wire DEBUG log
来源:https://stackoverflow.com/questions/44863533/disable-apache-http-wire-debug-logs