| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The client library uses SLF4J for all logging. If you want to turn on logging, you must include a plugin that bridges SLF4J with a concrete logging framework.
To quickly get you started and to serve as an example of how to do this, each example distribution uses the log4j framework, and includes sample log4j.properties and log4j.tofiles.properties files that show how you might configure logging if you decide to use log4j as your concrete logging framework.
Starting with release 3.5.0, all loggers use the following log levels:
| Response type | Summary level | Details level |
|---|---|---|
| Successful | INFO | DEBUG |
| Failed | WARN | INFO |
If you enable the INFO level on all loggers, your logs will contain summary messages for all requests and details for failed requests. This is the approach demonstrated in the sample log4j.properties files.
If you want details for all requests regardless of success or failure, enable the DEBUG level on all loggers.
The library includes the following loggers:
com.google.api.ads.dfp.lib.client.AdManagerServiceClient.soapXmlLogger
Logs incoming and outgoing SOAP requests/responses. SOAP requests and responses are logged as WARN for exceptions and INFO for all other requests. You can configure your logging framework to accept logs on these parameters.
com.google.api.ads.dfp.lib.client.AdManagerServiceClient.requestInfoLogger
Logs a single line summary of each request from the client library that includes information such as the timestamp, service, method, endpoint URL, and success or failure of the request.
To make it easier to enable logging in the example projects, each example project includes the log4j dependencies required at runtime, as well as two sample configuration files that enable the INFO level on all loggers.
If you downloaded a file like admanager-axis-jars-and-examples-v.vv.vv.tar.gz, it will already include:
Simply make sure that both the jars in src/lib and the src/log4j.properties file are in your classpath.
If you downloaded a file like admanager-axis-maven-and-examples-v.vv.vv.tar.gz, it will already include:
Maven should automatically include the log4j dependencies and the config file in your classpath, so logging will be enabled by default.
This is where the flexibility of SLF4J proves useful. You simply need to:
The SLF4J manual contains a list of bindings for common logging frameworks.
To use a different framework than log4j, remove the slf4j-log4j12-v.v.v.jar from your classpath and fetch a different one from http://www.slf4j.org/download.html.
To bridge SLF4J for a logging framework, you must include the plugin and logging framework dependencies in the dependencies list of your pom.xml file.
For example, if you want to use the log4j logging framework, add the following to your pom.xml file.
<!-- Adds the log4j framework --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <!-- Make SLF4J use log4j as the logging framework --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.7</version> </dependency>
If you want to use JDK logging, add the following to your pom.xml file.
<!-- Adds the log4j framework --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <!-- Make SLF4J use JDK logging as the logging framework --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jdk14</artifactId> <version>1.7.12</version> </dependency>
| Back | FazBrowse Home | New Git URL |