记录目的:java main 方法使用HttpClients发送请求不打印debug日志

记录背景
使用java main方法测试接口响应时间

发现问题
控制台打印巨多debug日志

解决方法:
resources目录下增加logback.xml

备注说明:
如果xml文件没有被编译,pom增加配置可以解决

 <resources><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes></resource><resource><directory>src/main/resources</directory><includes><include>**/*.xml</include></includes></resource></resources>

logback.xml

<configuration debug="false"><logger name="org.apache" level="INFO" /><logger name="org.apache.http.wire" level="INFO" /><logger name="org.apache.http.headers" level="INFO" /><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>

httpclient版本:

<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore --><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpcore</artifactId><version>4.4.10</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId><version>4.5.6</version></dependency>

pom.xml 全文件内容

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.0.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.lzx</groupId><artifactId>test</artifactId><version>0.0.1-SNAPSHOT</version><name>test</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore --><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpcore</artifactId><version>4.4.10</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId><version>4.5.6</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin><plugin><groupId>com.spotify</groupId><artifactId>docker-maven-plugin</artifactId><configuration><resources><resource><targetPath>/</targetPath><directory>${project.build.directory}</directory><include>${project.build.finalName}.jar</include></resource></resources></configuration></plugin></plugins><finalName>${project.artifactId}</finalName><resources><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes></resource><resource><directory>src/main/resources</directory><includes><include>**/*.xml</include></includes></resource></resources></build></project>

java main 方法使用 HttpClients发送请求 不打印debug日志相关推荐

  1. main方法中args_public static void main(String [] args)– Java main方法

    main方法中args public static void main(String[] args) is the most important Java method. When you start ...

  2. Java main方法

    public static void main(String[] args) {} 或者 public static void main(String args[]) {} main方法是我们学习Ja ...

  3. Java main方法_解释Java中的main方法,及其作用_一个java文件中可包含多个main方法

    public static void main(String[] args) {} 或者 public static void main(String args[]) {} main方法是我们学习Ja ...

  4. Maven exec:java 运行 Java main 方法

    目录 前言 适用条件 方法1 遇到错误:[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java (d ...

  5. java main方法里调用mapper

    在main方法中调用mybatis的mapper,一次性执行导入数据功能package com.runxsoft.test;import com.runxsoft.iutils.common.util ...

  6. java main方法背后的故事?(转)

    jvm java 看似一种语言,实则一个巨大的体系的王国,开发这么多年了,还是没有搞懂,我以为我懂了,可是过了一段时间又忘了,所以说还是没懂 1.main方法说起 编译完我们的java文件后,需要有个 ...

  7. Java main()方法

    在 Java 中,main() 方法是 Java 应用程序的入口方法,程序在运行的时候,第一个执行的方法就是 main() 方法.main() 方法和其他的方法有很大的不同. 下面先来看最简单的一个 ...

  8. Java main 方法详解

    1.main方法说起 编译完我们的java文件后,需要有个一含有main方法的类,java 命令将指示操作系统启动一个jvm进程 这个jvm进程启动后,寻找那个main地方开始执行程序 java [J ...

  9. 深入理解Java main方法

    在Java中,main()方法是Java应用程序的入口方法,也就是说,程序在运行的时候,第一个执行的方法就是main()方法,这个方法和其他的方法有很大的不同,例如 方法的名字必须是main 方法必须 ...

最新文章

  1. 要在 create-react-app 脚手架里使用 less 的方法
  2. java pdf转换为png图片(1)
  3. 017_html图像
  4. boost::container模块实现多态向量的测试程序
  5. [vue] 在.vue文件中style是必须的吗?那script是必须的吗?为什么?
  6. LeetCode 495. 提莫攻击
  7. AC日记——Mato的文件管理 bzoj 3289
  8. ECCV 2020 | 清华提出基于循环关联的自监督行人再识别, 无标签ReID仅需两个摄像头!...
  9. git push提交时卡住
  10. 计算机网络 课后题答案解析,计算机网络课后习题和答案解析
  11. Centos6.x升级内核方法支持Docker
  12. C语言学习——初始C语言
  13. 宗地图绘制要求和规范_国内土地市场宗地图的绘制标准制图规范-【领仕网】...
  14. 怎么取消linux ssh互信,[系统-linux] ssh互信操作
  15. python模拟浏览器访问企查查_python爬虫另辟蹊径绕过企查查的登录验证,我太冇财了...
  16. 花了500学的seo课程教程笔记公布
  17. 【面试】Raft算法详解
  18. 如何创建WordPress登陆页面模板
  19. 毕业论文word文档排版教程(动图的方式演示,针对wps)
  20. 从小白到web渗透工程师——零基础指南(2)sql注入漏洞

热门文章

  1. spritekit 动画_iOS SpriteKit 游戏
  2. C++字符输入方式详解
  3. 关于tkinter的的布局管理pack()篇
  4. 主域名与子域名的区别
  5. 景区夜游项目如何成功规划设计
  6. Python基础–详细记录Fourth_Chapter
  7. Web——KnockOut 绑定语法之事件
  8. Mac 不能打开文件夹xxx 因为您没有权限查看其内容
  9. 二维和三维CAD设计Autodesk AutoCAD 2021
  10. 什么是IA32 及字长的理解