Skip to main content
Published: December 02 2016, 5:18:00 PMUpdated: August 17 2022, 9:41:33 PM

 

Summary

   To enable logging in Java SDK,  you will need to do the following:

   1. set log4j.properties on your classpath. If your java source code is under the ../src/ folder,  you should put the log4j.properties into the same directory.    Here is a sample log4j.properties that logs the output to a file:

log4j.rootLogger = INFO, File

# file appender property
log4j.appender.File=org.apache.log4j.DailyRollingFileAppender

# log file name property
log4j.appender.File.File=${LOG FILE NAME}

# DatePattern property
log4j.appender.File.DatePattern='.' yyyy-MM-dd-a

# the layout property for file appender
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.conversionPattern=%m%n

 Note. you can also find a sample log4j.properties in  ${SDK Root}samples/consoleAddItemDirect/src folder for a Java standalone application or ${SDK Root}\samples\signinRedirect\src for a Java web application.


   2.  register ApiLogging object to the ApiContext object as below in your code :
        ApiLogging logging = new ApiLogging();
       apiContext.setApiLogging(apiLogging); 

 

 

How well did this answer your question?
Answers others found helpful