Skip to main content

Introducing Configurable Logging Support in Java and TypeScript

· 2 min read

We have introduced configurable logging for API calls in Java and TypeScript SDKs.

What's New?

Logging in a software application is essential when it comes to capturing activity data for troubleshooting, security auditing, and performance analysis, which can now be activated in SDKs using the EnableLogging codegen setting.

info:
x-codegen-settings:
EnableLogging: true

For more details on the EnableLogging CodegenSetting and its impact on SDK behavior, refer to the EnableLogging documentation.

Below are the logging configuration options that users can apply when logging API calls.

General Logging Configuration Options

  • Level: Defines the log message severity or priority (e.g., DEBUG, INFO, WARN, ERROR, FATAL).
  • Logger: Allows users to provide a custom logger implementation.
  • Mask Sensitive Headers: A global setting to mask sensitive HTTP headers in both requests and responses before logging, safeguarding confidential data.

Request Logging Configuration Options

  • Log Body: Controls the logging of the request body.
  • Log Headers: Controls the logging of request headers.
  • Exclude Headers: Excludes specified headers from the log output.
  • Include Headers: Includes only specified headers in the log output.
  • Unmask Headers: Logs specified headers without masking, revealing their actual values.
  • Include Query in Path: Determines whether to include query parameters in the logged request path.

Response Logging Configuration Options

  • Log Body: Controls the logging of the response body.
  • Log Headers: Controls the logging of response headers.
  • Exclude Headers: Excludes specified headers from the log output.
  • Include Headers: Includes only specified headers in the log output.
  • Unmask Headers: Logs specified headers without masking, revealing their actual values.

These configurations can be set during SDK client initialization. Below are examples demonstrating how to use these configurations in various programming languages.

SDKClient client = new SDKClient.Builder()
.loggingConfig(builder -> builder
.level(Level.DEBUG)
.maskSensitiveHeaders(true)
.requestConfig(reqConfig -> reqConfig
.body(true)
.headers(true)
.includeQueryInPath(true)
.includeHeaders("Content-Type", "Content-Encoding"))
.responseConfig(resConfig -> resConfig
.headers(true)
.excludeHeaders("X-Powered-By")))
.build();