HttpClient关闭Debug日志两种方式

方法一:代码开始位置添加这几行代码

System.setProperty("org.apache.commons.logging.LogFactory", "org.apache.commons.logging.impl.LogFactoryImpl");
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
LogFactory.getFactory().setAttribute("org.apache.commons.logging.simplelog.defaultlog", "error");

如果上面不生效

方法二:在resources目录下添加logback.xml

<configuration debug="false">
    <property name="CONSOLE_LOG_PATTERN" value="%date{yyyy-MM-dd HH:mm:ss}  %highlight(%-5level) %magenta(%-4relative) --- [%yellow(%15.15thread)] %cyan(%-40.40logger{39}) : %msg%n"/>
    
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}pattern>
        encoder>
    appender>
    <root level="ERROR">
        <appender-ref ref="STDOUT"/>
    root>
configuration>

你可能感兴趣的:(java)