HttpLoggingInterceptor 拦截的log信息为unicode字符时的解决办法
来源:互联网 发布:有哪些经典算法 编辑:程序博客网 时间:2024/05/24 06:14
问题现状
后台是PHP写的,后台返回的信息是经过unicode编码的,如果里面有中文,在控制面版上是无法直接查看的,如
{“code”:”4000”,”msg”:”\u767b\u5f55\u5931\u8d25”}
我的配置如下:
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(HttpLoggingInterceptor.Logger.DEFAULT); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient okHttpClient = new OkHttpClient().newBuilder() // 拦截 信息 并打印出来 .addInterceptor(interceptor) .build();
解决办法
重写logger,不要用HttpLoggingInterceptor.Logger.DEFAULT。
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() { @Override public void log(String message) { try { StringReader reader = new StringReader(message); Properties properties = new Properties(); properties.load(reader); properties.list(System.out); } catch (IOException e) { e.printStackTrace(); } } });
设置好了以后,后台返回的信息,可以很直观的查看了
{“code”=”4000”,”msg”:”登录失败”}
0 0
- HttpLoggingInterceptor 拦截的log信息为unicode字符时的解决办法
- HttpLoggingInterceptor 拦截的log信息为unicode字符时的解决办法
- HttpLoggingInterceptor的用法简介
- HttpLoggingInterceptor的用法简介
- unicode编码转换为字符的形式
- HttpLoggingInterceptor消息拦截器
- svn log 无法显示最近的信息解决办法
- 一段Unicode下的Log
- Unicode字符的概念
- unicode 字符的输出
- C#中将UNICODE编码后的字符转换为汉字
- UNICODE下宽字符的CString转换为const char *
- 24 Python assert,Exception的异常信息为unicode的中文时
- ReadString在UNICODE下中文乱码的解决办法(Char型字符和Unicode字符的转换问题)
- ReadString在UNICODE下中文乱码的解决办法(Char型字符和Unicode字符的转换问题)
- 彩色的log信息
- Unicode 字符编码表|汉字Unicode编码的区间为:0x4E00→0x9FA5
- Unicode 字符编码表|汉字Unicode编码的区间为:0x4E00→0x9FA5(转)
- 如何正确选择云服务?|创业公司做产品的感想
- spring框架学习(五)注解
- git 秘钥生成及常用指令
- 常用第三方开源框架介绍
- 超级简单四步使用KVO
- HttpLoggingInterceptor 拦截的log信息为unicode字符时的解决办法
- 如何检查 TEMP TABLESPACE 的使用情况
- spring框架学习(六)AOP
- hihocoder #1014 : Trie树
- 内存管理
- 欢迎使用CSDN-markdown编辑器
- 自己翻译制作的一些艺术字体
- 基于深度学习架构android人脸识别[离线版]APP免费下载。
- cocos2dx V3.2 mac os Xcode6.1 环境配置