MicroStrategy ONE

Implementing Logging for Custom Classes

It is important that you create a Log class for every package in which you have your custom classes.

For example, if you have your custom classes in package C and package D such that the qualified path is WEB-INF/classes/packageA/packageB/packageC and WEB-INF/classes/packageA/packageB/packageD, then classes in package C should have their own Log class and classes in package D should have their own Log class. It is not recommended to share Log classes across packages.

You can create a Log class for packageA.packageB.packageC using the sample code provided below.

package packageA.packageB.packageC;

import com.microstrategy.utils.log.*;

class Log

extends LoggerConfigurator {

 public static final Logger logger = new Log().createLogger();

}

Once the Log class is available, you can use a logger object for logging the messages. Having a logger for each package allows you to control the kind of logging you can perform in different packages.

There are several logging methods available for the Log class. For information on these methods, refer to the Logger class topic in the com.microstrategy.utils.log package of the API Reference.

See also