User guide
AmazonClientException
This exception indicates that a problem occurred inside the Java client code, either while trying to send
a request to AWS or while trying to parse a response from AWS. AmazonClientException exceptions
are more severe than AmazonServiceException exceptions and indicate a major problem that is
preventing the client from being able to make service calls to AWS services. For example, the AWS Java
SDK will throw an AmazonClientException if no network connection is available when you try to call
an operation on one of the clients.
IllegalArgumentException
When calling operations, if you pass an illegal argument, the AWS SDK for Java will throw an
IllegalArgumentException. For example, if you call an operation and pass a null value in for one of
the required parameters, the SDK will throw an IllegalArgumentException describing the illegal
argument.
Logging AWS SDK for Java Calls
The AWS SDK for Java is instrumented with Apache Commons Logging, which is an abstraction layer
that enables the use of any one of a number of logging systems at runtime. Supported logging systems
include the Java Logging Framework and Apache Log4j, among others. This topic explains how to use
Log4j.You can learn more about Log4j on the Log4j page at the Apache website.You can use the SDK's
logging functionality without making any changes to your application code.
Note
This topic focuses on Log4j 1.x. Log4j2 doesn't directly support Apache Commons Logging, but
provides an adapter that directs logging calls automatically to Log4j2 using the Apache Commons
Logging interface. For more information, see: Commons Logging Bridge in the Log4j2
documentation.
In order to use Log4j with the SDK, you need to download the Log4j jar from the Apache website.The
jar is not included in the SDK. Copy the jar file to a location that is on your classpath.
Log4j uses a configuration file, log4j.properties. Example configuration files are shown below. Copy this
configuration file to a directory on your classpath. The Log4j jar and the log4j.properties file do not have
to be in the same directory.
The log4j.properties configuration file specifies properties such as logging level, where logging output is
sent (such as to a file or to the console), and the format of the output.The logging level is the granularity
of output that the logger generates. Log4j supports the concept of multiple logging hierarchies.The logging
level is set independently for each hierarchy. The following two logging hierarchies are available in the
SDK.
• log4j.logger.com.amazonaws
• log4j.logger.org.apache.http.wire
Setting the Classpath
Both the Log4j jar and the log4j.properties file must be located on your classpath. If you are using Apache
Ant, set the classpath in the path element in your Ant file. Here is an example path element from the Ant
file for the Amazon S3 example included with the SDK:
<path id="aws.java.sdk.classpath">
Version v1.0.0
18
AWS SDK for Java Developer Guide
Logging