- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 Retrofit,我想记录我的响应和其他事情,我正在使用这个 https://futurestud.io/tutorials/retrofit-2-log-requests-and-responses类型,但我遇到了 Cant resolve setLevel 错误
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(Level.BODY); // i am getting error on this
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging); //this is also getting error
我正在用这个编译 'com.squareup.okhttp3:logging-interceptor:3.3.1' 和 Retrofit编译 'com.squareup.retrofit2:converter-gson:2.1.0' 依赖项。
最佳答案
在getClient()
方法中编写您的拦截器
代码
public class RestClient {
public getClient() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
}
}
关于android - 无法在 HttpLoggingInterceptor Retrofit 2.0 上解析 setLevel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39784243/
我试图了解 logger.setLevel 的影响和 handler.setLevel 的影响之间的区别,其中 logger 和处理程序创建如下: import logging def getLogg
我在我的项目中使用了 java.util.Logger 并且我使用了一个简单的 ConsoleHandler。默认情况下,日志记录级别为“信息”。我想将级别更改为“良好”。但是,我必须同时更改 Log
我花了一些时间浏览网站上的 Python 记录器问题,希望我的问题能在那里得到解决。我已经设置了一个带有两个流处理程序的记录器,它们具有不同的格式和日志记录级别,这是我的代码库中的一个功能片段: im
我正在尝试在我的应用程序中使用此代码: def logger(log_file='base.log', set_level='INFO', identity='base'): set_le
此代码中是否有任何内容可以解释为什么我的信息消息没有进入日志。格式正确的警告及以上警告将进入两个日志文件。 初始化记录器: logger = logging.getLogger() f = loggi
情况:我有这个 log4j 记录器: private static final Logger logger = Logger.getLogger(ThisClassName.class); 我正在尝试
看看这个链接:https://docs.python.org/3/library/logging.html#levels 他们谈论日志级别,其中 DEBUG 的数值为 10,INFO 的数值为 20.
我正在尝试缩放可绘制对象但失败了。然而,这不是本例的问题,它似乎与 setLevel() 方法有关。 我很难从它声明的文档中弄清楚它的作用以及我应该在什么时候使用它: Specify the leve
我有一个 python 程序,它利用多处理来提高效率,以及一个为每个进程创建记录器的函数。记录器函数如下所示: import logging import os def create_logger(a
Deflater.setLevel()对我来说没有预期的效果。 static void test1() throws Exception { byte[] output = new byte
以下代码是从文档中复制的。我应该能够看到所有的信息日志。但我没有。即使我将 setLevel 设置为 INFO,我也只能看到警告及以上。 为什么会这样? foo.py: import logging
在 logging howto documentation有这个例子: import logging # create logger logger = logging.getLogger('simpl
假设我有以下代码: import logging import logging.handlers a = logging.getLogger('myapp') h = logging.handlers
我实现了一个 netty 4 http 服务器。 public void start() { System.out.println("In Start method"); try {
fmtter = logging.Formatter('%(asctime)s,%(msecs)05.1f (%(funcName)s) %(message)s', '%H:%M:%S') rock_
我正在尝试将可绘制对象存储在静态 SoftReferenceMap 中,用于每行包含进度条的 ListView。每行都有不同的进度,但是当我通过 setProgress(int) 设置它时,所有行都会
我正在尝试过滤来自 UDP 的 Python 日志消息,但出于某种原因,在接收端设置日志级别似乎不会影响传入消息。 接收端代码如下: import cPickle import logging imp
setLevel(okhttp3.logging.HttpLoggingInterceptor.Level)' 已弃用 setLevel 应该替换什么?删除已弃用的问题 最佳答案 根据文档“移动到 v
我有如下设置日志记录: def setUp(): LOG_FORMAT = '%(asctime)s %(levelname)-8s %(name)s %(message)s' #LO
假设我有以下代码: import logging import logging.handlers a = logging.getLogger('myapp') h = logging.handlers
我是一名优秀的程序员,十分优秀!