@@ -260,6 +260,87 @@ try (CampaignServiceClient reportingServiceClient = googleAdsClient.getCampaignS
260260}
261261```
262262
263+ ### Request/Response Logging
264+
265+ Logging is configured with SLF4J a generic logging library for Java, which allows logs to be
266+ directed to many different logging implementations. We provide configuration files for log4j 1.2/2.0
267+ and Java Util Logging (JUL).
268+
269+ #### Logging layout and functionality
270+
271+ Requests are logged with a one line summary and the full request/response body and
272+ headers.
273+
274+ | Log type | Log name | Success level | Failure level |
275+ | -------- | -------------------------------------------- | ------------- | ------------- |
276+ | SUMMARY | com.google.ads.googleads.lib.request.summary | INFO | WARN |
277+ | DETAIL | com.google.ads.googleads.lib.request.detail | DEBUG | INFO |
278+
279+ #### Detail Log Truncation
280+
281+ The detailed logs are truncated by default to avoid creating large logs. To change the length at
282+ which logs are truncated, set ` -Dapi.googleads.maxLogMessageLength=<number> ` . Setting -1 disables
283+ log truncation.
284+
285+ #### Log4j 2.0
286+
287+ 1 . Add a dependency on the ` log4j-slf4j-impl ` library.
288+
289+ ```
290+ <dependency>
291+ <groupId>org.apache.logging.log4j</groupId>
292+ <artifactId>log4j-slf4j-impl</artifactId>
293+ <version>2.11.1</version>
294+ </dependency>
295+ ```
296+
297+ 2 . (Optional) Create a configuration file in your resources directory, e.g. in Maven
298+ ` src/main/resources ` . Log4j 2.0 loads its configuration file from the classpath, not the working
299+ directory, so ensure you create in a resources directory.
300+
301+ 3 . Run your application, specifying ` -Dlog4j.configurationFile=<CONFIG_FILE_PATH> ` . You can specify
302+ ` CONFIG_FILE_PATH=googleads-logging/log4j2.xml ` to use the default configuration file included
303+ with the client libraries.
304+
305+ #### Log4j 1.2 (legacy)
306+
307+ 1 . Add a dependency on the ` slf4j-log4j12 ` library.
308+
309+ ```
310+ <dependency>
311+ <groupId>org.slf4j</groupId>
312+ <artifactId>slf4j-log4j12</artifactId>
313+ <version>1.7.25</version>
314+ </dependency>
315+ ```
316+
317+ 2 . (Optional) Create a configuration file in your projects resources directory, e.g. in Maven
318+ path is ` src/main/resources ` . Log4j 1.2 loads its configuration file from the classpath, not the
319+ working directory, so ensure you copy to a resources directory.
320+
321+ 3 . Run your application, specifying ` -Dlog4j.configuration=<CONFIG_FILE_PATH> ` . You can specify
322+ ` CONFIG_FILE_PATH=googleads-logging/log4j.properties ` to use the default configuration file included
323+ with the client libraries.
324+
325+ #### Java Util Logging
326+
327+ 1 . Add a dependency on the ` slf4j-jdk14 ` library.
328+
329+ ```
330+ <dependency>
331+ <groupId>org.slf4j</groupId>
332+ <artifactId>slf4j-jdk14</artifactId>
333+ <version>1.7.25</version>
334+ </dependency>
335+ ```
336+
337+ 2 . Create a JUL configuration file on the file system in a path readable from your application. For
338+ instance ` ./jdk-logger.properties ` . A template is provided at
339+ ` google-ads/src/main/resources/googleads-logging/jdk-logger.properties ` . JUL reads from the
340+ filesystem only, so do not copy to the resources directory.
341+
342+ 3 . Run your application specifying ` -Djava.util.logging.config.file=./jdk-logger.properties ` .
343+
263344## Miscellaneous
264345
265346### Wiki
0 commit comments