When integrating customizations into the Strategy Web and Web Universal 9.x products, it is recommended to incorporate logging into the custom code. This will be of great assistance to the developer should complications or errors surface anytime during the development or testing process. To accomplish this, perform the following steps:
- Create a custom logger class. The logger class should be coded as follows:
package customclasses.transforms;
import com.Strategy.utils.log.*;
public class Log extends LoggerConfigurator {
public static final Logger logger = new Log().createLogger();
public Log() {
super();
}
- public static boolean isLoggable(Level theLevel)
{
return Log.logger.isLoggable(theLevel);
}
public static void generateLog(Level theLevel, String className,
String method, String msg)
{
Log.logger.logp(theLevel, className, method, msg);
}
}
A logger class should be created for each custom package. For example, create a separate logger file for both the 'customclasses.transforms' and the 'customclasses.addons' custom packages.
Code Customization
WARNING:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy may not be able to provide additional code on this matter even though this customization is provided at this time for this specific build.
- Modify the custom code to include calls to the custom logger, as shown in the following sample code:
package customclasses.transforms;
import com.Strategy.utils.log.Level;
import com.Strategy.web.app.transforms.ReportGridTransformImpl;
import com.Strategy.web.beans.MarkupOutput;
import com.Strategy.web.beans.ReportBean;
import com.Strategy.web.beans.WebBeanException;
public class CustomReportGridTransformImpl extends ReportGridTransformImpl {
- private static final String CLASS_NAME = "customclasses.transforms.CustomReportGridTransformImpl";
private static Level FINE = Level.FINE;
private static Level WARN = Level.WARNING;
private static Level ERROR = Level.SEVERE;
public CustomReportGridTransformImpl() {
super();
}
public void renderGrid(MarkupOutput mo) {
String METHOD_NAME = "renderGrid";
if (Log.isLoggable(WARN))
{
Log.generateLog(WARN, CLASS_NAME, METHOD_NAME, "Entering my customfunction");
}
ReportBean rb = this.getReportBean();
try {
if (Log.isLoggable(WARN))
{
Log.generateLog(WARN, CLASS_NAME, METHOD_NAME, "Current Report: "+rb.getObjectName());
}
//call the superclass...
super.renderGrid(mo);
} catch (WebBeanException e) {
if (Log.isLoggable(ERROR))
{
Log.generateLog(ERROR, CLASS_NAME, METHOD_NAME, e.getMessage());
}
}
}
}
Modify the Strategy Web 9.x Administration page under the 'Configuration' section. Under the 'Advanced Logger Options', select the option 'Enable logging for multiple/other package(s)'. Specify the name of the custom package and set the level. The level can be set to 'Warning' or 'ALL' during development and in production it can be set to 'Severe', for example, as shown below: