In your connector code, make sure to import the logger libraries. Also, as mentioned previously, log level info
and higher is printed by default. If you want lower log levels, like debug
and trace
to show in your ccg.log file, you will need to modify your log4j2.properties file as mentioned previously. Please see below for sample connector code with logging statements.
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import connector.common.Util;
log.info("Entering GuruBeforeOperationRule");
log.info("Listing Variables passed to Beanshell namespace:");
// BeanShell has a "this.variables" array that we can access.
for (int i = 0 ; i < this.variables.length ; i++) {
String varName = this.variables[i];
Object varValue = null;
try {
if ("transient".equals(varName))
varValue = "[reserved word]";
else
varValue = eval(varName);
} catch (Exception ex) {
varValue = "[eval exception]";
}
String varClass = "void";
if ((void != varValue) && (null != varValue))
varClass = varValue.getClass().getSimpleName();
if (void == varValue)
log.info(varName + " = void");
else if (null == varValue)
log.info(varName + " = null");
else
log.info(varName + ": " + varClass + " = " + varValue);
}
Map tMap = (Map) application.getAttributeValue("transientValues");
if(null != tMap) {
String nextLink = tMap.get("nextLink");
log.info("nextLink : " + nextLink);
if(!Util.isEmpty(nextLink)) {
requestEndPoint.setFullUrl(nextLink);
log.info("Full url is now: " + requestEndPoint.getFullUrl());
}
}
log.info("Leaving GuruBeforeOperationRule: " + requestEndPoint);
return requestEndPoint;