“I’m using the Java DevKit, and my IDS calls are failing. How can I troubleshoot?” - we get asked this question very often and the solution is to enable logging in the DevKit!
Here is an easy-to-follow, step by step guide to enable logging of the request and response XML in the Java DevKit.
The IPP Java DevKit 2.0.7 uses SLF4j as the logging mechanism. SLF4j (Simple Logging Façade for Java) serves as an abstraction layer for the various Java logging frameworks like java.util.logging, log4j and logback. The actual framework to be used by the application can be determined at compile time by adding the static binding to the classpath.
The DevKit implements SLF4j and includes the slf4j-api-1.6.4.jar. The logger that is implemented in the Java dev kit is “com.intuit.platform” . The acceptable logging levels depend on the logging framework configured in the application’s config file.
Why we use SLF4j
- Developer is not bound to use the same logging framework as the underlying library, so it gives the developer the flexibility to configure the logging framework at deployment time. Applications that rely on the Java DevKit can now use any logging mechanism – JUL, Log4j or Logback.
- Slf4j uses parameterized logging messages for improved performance.
Here’s an example that shows how to enable log4j logging for an app using the Java DevKit - HelloWorldIA is an existing Java application that integrates with the IPP Java DevKit.
1. Bind the Logging framework - Download and reference the log4j.jar and SLF4j binding jar slf4j-log4j12-1.6.4.jar to the application POM.xml. The jars for SLF4J binding can be downloaded from here.
Note: If no binding file is found on the classpath, it will default to a no-operation implementation. You will see the following warning message in the console log:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details
2. Configure the logging framework - Include the log4j.properties in the src folder and set the DevKit logging level as com.intuit.platform.level=DEBUG
Setting the level to debug will write the request and response XMLs to the log file. The other log level that is currently implemented in the DevKit is WARN that writes the warning messages to the logs.
For more details on the configuration for other logging frameworks, please refer to the documentation here.
- Priyadarshini Vijayakumar - IPP Developer Relations