How to get a list of NOC logging categories for troubleshooting purpose

  • 7008229
  • 29-Mar-2011
  • 26-Jun-2012

Environment

Novell Operations Center Business Service Manager 4.7
Novell Operations Center Business Service Manager 4.5
Novell Operations Center Business Service Manager 4.0

Situation

NOC uses log4j libraries for logging services. These libraries are designed in such a way that specific logging category can be added (or removed) at the runtime.It means any Java class when being instantiated, or during its lifetime, can add a new logger for its specific needs. This feature has for sure its advantages. Unfortunately, it also has at least one disadvantage, namely the fact that the user without access to the source code usually does not know which logging category has been added by which class. The information about existing and usable logging categories is important for troubleshooting.
NOC Java client offers specifically designed menu (available from Administration->Server->rclick->Logging), which allows to browse (and set) existing logging categories using the graphical tree view. This is really cool feature, but using this tree also becomes  difficult in case there are several hundred active loggers, and we don't know for sure what we are after. The other disadvantage is that the Java client must be up and running, which means this logging menu cannot be used in early NOC load phases, and it also can hardly be used against the Java client itself, for example in case client does not start over SSL connection. Therefore for troubleshooting purposes a list of all currently existing logging categories (=registered loggers) might be required. Having such list helps then to choose which logger can currently be set into output rich DEBUG mode.

Resolution

Fortunately, log4j libraries also offer mechanism which allows to list names of all registered loggers.These loggers are usually named in relation to the Java class, they are used in. To list these loggers in fscript is as easy as this:

var logList = Packages.org.apache.log4j.Logger.getDefaultHierarchy().getCurrentLoggers();
while(logList.hasMoreElements())
    {
     var elem = logList.nextElement();
     myStream.println(elem.getName());    
     }

Using the code above we can create small but complete server-side formula script, which opens separate output file and writes all existing loggers into it. Here is the complete code:

var filename = 'C:\\ManagedObjects\\log4j-categories.log';    // for Windows environment
var myStream = new java.io.PrintWriter( new java.io.FileOutputStream( filename, true ) );    
myStream.println('Following log4j categories have been found on this box:');       
var logList = Packages.org.apache.log4j.Logger.getDefaultHierarchy().getCurrentLoggers();
while(logList.hasMoreElements())
    {
     var elem = logList.nextElement();
     myStream.println(elem.getName());    
     }         
myStream.flush();
myStream.close();   

This server-side code can be run as it is from an operation definition, or from an automation definition. It lists all loggers registered under formula JVM. The code can also be used from formula script command line, but in this case it would return only very limited logger information, related to the Java sandbox in which formula script command line tool is being kept.

Knowing all currently registered loggers helps then during the troubleshooting process. For example if we are after the problem which is related to time management configuration, we can easily discover from this list that the system has at least one related logger registered, namely TimeManagementConfig, and we can set this logger into the DEBUG mode by adding the following line to our Formula.custom.properties file:
log4j.category.TimeManagementConfig=DEBUG

Feedback service temporarily unavailable. For content questions or problems, please contact Support.