AI-generated Key Takeaways
- 
          Logging is configured using SLF4J and supports log4j 1.2/2 and Java Util Logging. 
- 
          Requests are logged with both a one-line summary and full detail including body and headers. 
- 
          Detail logs are truncated by default but can be adjusted or disabled. 
- 
          Configuration steps are provided for Log4j 2, Log4j 1.2, and Java Util Logging. 
Logging is configured with SLF4J a generic logging library for Java, which allows logs to be directed to many different logging implementations. We provide configuration files for log4j 1.2/2 and Java Util Logging (JUL).
Logging layout and functionality
Requests are logged with a one line summary and the full request/response body and headers.
| Log type | Log name | Success level | Failure level | 
|---|---|---|---|
| SUMMARY | com.google.ads.googleads.lib.request.summary | INFO | WARN | 
| DETAIL | com.google.ads.googleads.lib.request.detail | DEBUG | INFO | 
Detail Log Truncation
The detailed logs are truncated by default to avoid creating large logs. To
change the length at which logs are truncated, set
-Dapi.googleads.maxLogMessageLength=<number>. Setting -1 disables
log truncation.
Log4j 2
- Add a dependency on the - log4j-slf4j-impllibrary, substituting- 2.x.ywith the version of Log4j 2 you are using in your project.- <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <version>2.x.y</version> </dependency>
- (Optional) Create a configuration file in your resources directory, for example, in Maven: - src/main/resources. Log4j 2 loads its configuration file from the classpath, not the working directory, so ensure you create in a resources directory.
- Run your application, specifying - -Dlog4j.configurationFile=<CONFIG_FILE_PATH>. You can specify- CONFIG_FILE_PATH=googleads-logging/log4j2.xmlto use the default configuration file included with the client libraries.
Log4j 1.2 (legacy)
- Add a dependency on the - slf4j-log4j12library, substituting- 1.x.ywith the version of Log4j 1.2 you are using in your project.- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.x.y</version> </dependency>
- (Optional) Create a configuration file in your projects resources directory, for example, in Maven, path is - src/main/resources. Log4j 1.2 loads its configuration file from the classpath, not the working directory, so ensure you copy to a resources directory.
- Run your application, specifying - -Dlog4j.configuration=<CONFIG_FILE_PATH>. You can specify- CONFIG_FILE_PATH=googleads-logging/log4j.propertiesto use the default configuration file includedwith the client libraries.
Java Util Logging
- Add a dependency on the - slf4j-jdk14library.- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jdk14</artifactId> <version>1.7.25</version> </dependency>
- Create a JUL configuration file on the file system in a path readable from your application (for instance, - ./jdk-logger.properties). A template is provided at- google-ads/src/main/resources/googleads-logging/jdk-logger.properties. JUL reads from the filesystem only, so do not copy to the resources directory.
- Run your application specifying - -Djava.util.logging.config.file=./jdk-logger.properties.