Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.7.0 - 2019-02-01
------------------
Added support and examples for Google Ads API v0_7.

- Added support for request level logging.
- Added GetHotelAdsPerformance example.
- Updated GetKeywordStats example with segments prefix.

0.6.0 - 2018-12-03
------------------
Added support and examples for Google Ads API v0_6.
Expand Down
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,87 @@ try (CampaignServiceClient reportingServiceClient = googleAdsClient.getCampaignS
}
```

### Request/Response 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.0
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.0

1. Add a dependency on the `log4j-slf4j-impl` library.

```
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>
```

2. (Optional) Create a configuration file in your resources directory, e.g. in Maven
`src/main/resources`. Log4j 2.0 loads its configuration file from the classpath, not the working
directory, so ensure you create in a resources directory.

3. Run your application, specifying `-Dlog4j.configurationFile=<CONFIG_FILE_PATH>`. You can specify
`CONFIG_FILE_PATH=googleads-logging/log4j2.xml` to use the default configuration file included
with the client libraries.

#### Log4j 1.2 (legacy)

1. Add a dependency on the `slf4j-log4j12` library.

```
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
```

2. (Optional) Create a configuration file in your projects resources directory, e.g. 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.

3. Run your application, specifying `-Dlog4j.configuration=<CONFIG_FILE_PATH>`. You can specify
`CONFIG_FILE_PATH=googleads-logging/log4j.properties` to use the default configuration file included
with the client libraries.

#### Java Util Logging

1. Add a dependency on the `slf4j-jdk14` library.

```
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>
```

2. 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.

3. Run your application specifying `-Djava.util.logging.config.file=./jdk-logger.properties`.

## Miscellaneous

### Wiki
Expand Down
10 changes: 8 additions & 2 deletions google-ads-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
* specific language governing permissions and limitations
* under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
<groupId>com.google.api-ads</groupId>
Expand Down Expand Up @@ -67,6 +68,11 @@
<artifactId>joda-time</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private void runExample(
googleAdsClient.getRecommendationServiceClient()) {
ApplyRecommendationResponse response =
recommendationServiceClient.applyRecommendation(
Long.toString(customerId), false, operations);
Long.toString(customerId), operations);
System.out.printf("Applied %d recommendation:%n", response.getResultsCount());
for (ApplyRecommendationResult result : response.getResultsList()) {
System.out.println(result.getResourceName());
Expand Down
Loading