EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB14850: How to debug and configure diagnostics for custom code in MicroStrategy Web SDK 9.x


Community Admin

• Strategy


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:
 

  1. 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();
         }
     
  2.      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:
     
ka04W000000OfnIQAS_0EM440000002H0M.gif
  • Now in Strategy Web 9.x, perform the action to invoke the custom code.
  • Under the WEB-INF/Log folder, a new file appears with the name of the custom package, for example, 'AdvMSTRLogcustomclasses_transforms09282006_1.log'
  • When viewing the contents of the custom diagnostics file, the messages will appear similar to the following:
    <record>
         <package>customclasses.transforms</package>
         <level>WARNING</level>
         <miliseconds>1159472673545</miliseconds>
         <timestamp>09/28/2006 15:44:33:545</timestamp>
         <thread>3</thread>
     
         <class>CustomReportGridTransformImpl</class>
     

  •      <method>renderGrid</method>

         <message>Entering my customfunction</message>

         <userName>Administrator</userName>
         <clientID>127.0.0.1</clientID>
    </record>
    <record>
         <package>customclasses.transforms</package>
         <level>WARNING</level>
         <miliseconds>1159472687616</miliseconds>
         <timestamp>09/28/2006 15:44:47:616</timestamp>
         <thread>3</thread>
     
         <class>CustomReportGridTransformImpl</class>
     

         <method>renderGrid</method>

         <message> Current Report: Category Sales Report</message>

         <userName>Administrator</userName>
         <clientID>127.0.0.1</clientID>
    </record>

Comment

0 comments

Details

Knowledge Article

Published:

August 11, 2017

Last Updated:

August 11, 2017