Apache HttpClient库里的日志实现检测原理
2023-09-14 09:03:09 时间
我有一个业务类,里面指定了org.apache.commons.logging.impl.SimpleLog作为日志记录的实现。代码如下。
public SimpleContactCreator(){
enableHeaderWireAndContextLogging();
}
private void enableHeaderWireAndContextLogging(){
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
}
在运行时,这个SimpleLog的实现是如何被HttpClient检测出来的?
当我调用HttpClientBuilder.create().build()的时候,log检测就发生了:
查看方法findUserSpecifiedLogClassName:
从system property里取属性org.apache.commons.logging.Log的值:
这里就是我配置的SimpleLog。
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
相关文章
- Apache Solr介绍及安装
- Apache-Axis小结
- Apache RocketMQ 荣获 2021 中国开源云联盟优秀开源项目
- 解决Apache的错误日志巨大的问题以及关闭Apache web日志记录
- 解决Exception in thread “main“ org.apache.spark.SparkException: When running with master ‘yarn‘ either
- Apache Shiro 框架简介和下载导入
- 处理Apache日志的Bash脚本
- The APR based Apache Tomcat Native library which allows optimal performance in production 问题的解决
- Eclipse Server runtime设置里找不到apache tomcat的处理方法
- Caused by: org.apache.ibatis.reflection.ReflectionException我碰到的情况,原因不唯一
- 【实施工程师】Wampserver64橙色无法启动【apache】问题
- java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
- Log4J是Apache组织的开源一个开源项目,通过Log4J,可以指定日志信息输出的目的地,如console、file等。Log4J采用日志级别机制,请按照输出级别由低到高的顺序写出日志输出级别。
- idea启动tomcat报错,org.apache.tomcat.util.modeler.BaseModelMBean.invoke 调用方法[manageApp]时发生异常
- Apache Kafka 集群架构