> This page is for SDK, version Legacy.
> For other versions, use one of these documentation indexes:
> - Current (default): https://buildwithfern.com/learn/sdks/current/llms.txt
> - Legacy: https://buildwithfern.com/learn/sdks/legacy/llms.txt

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

## 3.39.0

**`(feat):`** 为生成的 SDK 添加日志记录支持。
用户可以通过向客户端构建器的 `.logging()` 方法传递 `LogConfig` 来配置日志记录。

```java
import com.example.api.AcmeApiClient;
import com.example.api.core.LogConfig;
import com.example.api.core.LogLevel;
import com.example.api.core.ConsoleLogger;

AcmeApiClient client = AcmeApiClient.builder()
    .token("YOUR_TOKEN")
    .logging(LogConfig.builder()
        .level(LogLevel.DEBUG)        // INFO 是默认值
        .logger(new ConsoleLogger())  // ConsoleLogger 是默认值
        .silent(false)                // true 是默认值，设置为 false 以启用日志记录
        .build())
    .build();
```

`LogConfig` 构建器接受以下属性：

* `level(LogLevel)`：要使用的日志级别。默认为 `LogLevel.INFO`。
* `logger(ILogger)`：要使用的日志记录器实现。默认为 `ConsoleLogger`。
* `silent(boolean)`：是否静默日志记录器。默认为 `true`。

`LogLevel` 枚举支持以下值：

* `DEBUG`
* `INFO`
* `WARN`
* `ERROR`

要提供自定义日志记录器，请实现带有 `debug`、`info`、`warn` 和 `error` 方法的 `ILogger` 接口。

HTTP 请求和响应详细信息（方法、URL、状态码、头部、正文）通过添加到 OkHttp 客户端的 `LoggingInterceptor` 记录。敏感头部（`authorization`、`x-api-key`、`cookie`、`x-csrf-token` 等）在日志中自动被编辑。