DocumentationTargetTarget Developer Guide

Logger (Java)

Last update: February 27, 2025
  • Topics:
  • APIs/SDKs

CREATED FOR:

  • Developer

Description

When initializing the SDK, there are several options on the ClientConfig object, which can be set to log requests.

OptionDescription
logRequestsLogs whole request body as well as response body.
logRequestStatusLogs request’s url, status along with response time.

Target Java SDK uses slf4j logging. You need to provide your implementation of logger such as java.util.logging, logback, and log4j. Refer to https://www.slf4j.org/manual.html for more information. All logs will be printed in debug.

Example

Add the slf4j dependency.

Gradle

compile 'org.slf4j:slf4j-simple:2.0.0-alpha0'
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>2.0.0-alpha0</version>
</dependency>

Enable the DEBUG logs based on your implementation, and mark the request logging flags.

Debug

System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
ClientConfig config = ClientConfig.builder()
        .client("acmeclient")
        .organizationId("1234567890@AdobeOrg")
        .logRequests(true)
        .logRequestStatus(true)
        .build();

TargetClient targetClient = TargetClient.create(config);

You should see requests, responses, and response times being printed in the console.

recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3