IBM Support

Trace Logging in Maximo

Technical Blog Post


Abstract

Trace Logging in Maximo

Body

Trace logging is a powerful tool that can log debug data in Maximo. It is used to log calls to methods in the Maximo classes so you can see what methods the code is calling. You can also add information to the log on what parameters were passed in and what was returned from the method. If you want even more information, you can create a stack trace to see what method called the method you are tracking. This logging does require some additional setup and have a performance hit since it's using byte code injection through a Java agent. The trace logging works on all  supported Maximo 7.5 versions and Maximo 7.6.0.4 and above. If you want to enable Trace Logging on an earlier version of Maximo 7.6, you need to download aspectjweaver-1.7.4.jar from the Maven repository, put this file in the [Maximo_Home]\applications\maximo\lib\ directory and delete the current aspectjweaver.jar, then rename aspectjweaver-1.7.4.jar to aspectjweaver.jar.

WebLogic Setup

Copy the [Maximo_Home]\applications\maximo\lib\aspectjweaver.jar file to [BEA_Home]\Middleware\user_projects\domains\[Domain_Home]\lib.
Open up the setDomainEnv.cmd file for our domain and find the following row,
set JAVA_OPTIONS=%JAVA_OPTIONS% %JAVA_PROPERTIES% -Dwlw.iterativeDev=%iterativeDevFlag% -Dwlw.testConsole=%testConsoleFlag% -Dwlw.logErrorsToConsole=%logErrorsToConsoleFlag%
Append "-javaagent:%DOMAIN_HOME%/lib/aspectjweaver.jar" to the end of the line,
set JAVA_OPTIONS=%JAVA_OPTIONS% %JAVA_PROPERTIES% -Dwlw.iterativeDev=%iterativeDevFlag% -Dwlw.testConsole=%testConsoleFlag% -Dwlw.logErrorsToConsole=%logErrorsToConsoleFlag% -javaagent:%DOMAIN_HOME%/lib/aspectjweaver.jar
Restart WebLogic

Websphere Setup

Copy the [Maximo_Home]\applications\maximo\lib\aspectjweaver.jar file to the [WebSphere]/AppServer/lib directory.
Log into the WAS console and click the Application Servers link in the left pane. Click on the MXSERVER in the middle pane.
Under the Server Infrastructure section click Java and Process Management and then click Process Definition. Under the Additional Properties section click Java Virtual Machine.
Configure the JVM by editing the Generic JVM Arguments to include the JavaAgent, add the following: -javaagent:[WebSphere]/AppServer/lib/aspectjweaver.jar
Click OK and then click Save. Click OK to return to the main Admin console and restart the server associated with Maximo

 

You might run into problems if your path includes spaces, if so, just move the aspectjweaver.jar to a directory on your server without spaces in your path.

Maximo Setup

In Maximo, go to Logging and find the Trace logger, filter for trace in the logger name. Make sure the Log i Active and have a Logging Level of Info. You can turn the logging off by setting the Log level to Debug but it is recommended to remove the JavaAgent from the server. This Logger has it's own File appender, if the root logging folder is specified, you can see the results in it's own file.

The result can be seen in the console and the new file,
2016-02-02 13:29:50:838 > psdi.mbo.Mbo.getMboSet(Mbo.java:3272)
2016-02-02 13:29:50:838  > psdi.mbo.Mbo.getMboValueData(Mbo.java:1420)
2016-02-02 13:29:50:838  < psdi.mbo.Mbo.getMboValueData(Mbo.java:1420)
2016-02-02 13:29:50:838  > psdi.mbo.Mbo.getMboValueData(Mbo.java:1420)
2016-02-02 13:29:50:838  < psdi.mbo.Mbo.getMboValueData(Mbo.java:1420)
2016-02-02 13:29:50:838 < psdi.mbo.Mbo.getMboSet(Mbo.java:3272)
2016-02-02 13:29:50:841 > psdi.mbo.Mbo.getMboSet(Mbo.java:3272)
2016-02-02 13:29:50:841  > psdi.mbo.Mbo.getMboValueData(Mbo.java:1420)
2016-02-02 13:29:50:841  < psdi.mbo.Mbo.getMboValueData(Mbo.java:1420)
2016-02-02 13:29:50:841  > psdi.mbo.Mbo.getMboValueData(Mbo.java:1420)
2016-02-02 13:29:50:841  < psdi.mbo.Mbo.getMboValueData(Mbo.java:1420)
2016-02-02 13:29:50:841 < psdi.mbo.Mbo.getMboSet(Mbo.java:3272)

Specifying methods to log

Out of the box this will only log annotated methods in Maximo. These are annotations specified by the developers and cannot be changed by clients.

       @TracePrimary

       public String someMaximoMethod(int start, int end, String data[]) throws RemoteException

       {...

If you do write custom code, you can include your own annotation by adding the "@TracePrimary" annotation to your methods. Keep in mind you also need to include the scope in the aop.xml file.

 

Let's say you want to enable trace logging for  the psdi.util.MXFormat.stringToDateTime() method in Maximo.

To specify your own methods to log, open up the [Maximo_Home]\applications\maximo\businessobjects\classes\META-INF\aop.xml file.

In the beginning of this file there is a <weaver> tag, in the tag, add your own include tag specifying the package to include,

       <!-- Additional tracking -->
       <include within="psdi.util..*" />

This will enable logging on the  psdi.util.* package and it's classes with methods.

 

Next find the <aspects> tag and edit the following tag,

       <concrete-aspect name="EntryExitTracing"
               extends="psdi.util.logging.EntryExitTracing"
                  >

You can choose between the the three different levels,

psdi.util.logging.EntryExitTracing, psdi.util.logging.EntryExitTracingWithParameters or psdi.util.logging.EntryExitTracingWithAllParametersAndStack

For example, change it to,

       <concrete-aspect name="EntryExitTracing"
               extends="psdi.util.logging.EntryExitTracingWithParameters"
                  >

To specify the actual method to log, add it to the <pointcut> tag,

       <pointcut name="scope" expression=
           "execution(@psdi.util.logging.annotations.TracePrimary * *(..))
           || execution(@psdi.util.logging.annotations.TracePrimary *.new(..))
           || execution(* psdi.util.MXFormat.stringToDateTime(..))"
           />

Save and restart Maximo, the result is something like,

2016-02-02 13:36:44:185 > psdi.mbo.MboSet.setQbe(MboSet.java:10798)(STARTTIME, <=2/2/16 1:36 PM) - psdi.app.report.ReportJobSet@ed5027ce

2016-02-02 13:36:44:185  > psdi.util.MXFormat.stringToDateTime(MXFormat.java:1095)(2/2/16 1:36 PM, en_US, sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]])

2016-02-02 13:36:44:187  < psdi.util.MXFormat.stringToDateTime(MXFormat.java:1095) : Tue Feb 02 13:36:00 CST 2016

2016-02-02 13:36:44:194  > psdi.util.MXFormat.stringToDateTime(MXFormat.java:1095)(2/2/16 1:36 PM, en_US, sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]])

2016-02-02 13:36:44:195  < psdi.util.MXFormat.stringToDateTime(MXFormat.java:1095) : Tue Feb 02 13:36:00 CST 2016

2016-02-02 13:36:44:195 < psdi.mbo.MboSet.setQbe(MboSet.java:10798) : null

 

We can now see the parameters passed into the method and also what was returned from the method.

To log all methods in a class, just replace the methodname with a star,

       <pointcut name="scope" expression=
           "execution(@psdi.util.logging.annotations.TracePrimary * *(..))
           || execution(@psdi.util.logging.annotations.TracePrimary *.new(..))
           || execution(* psdi.util.MXFormat.*(..))"
           />

Be careful when specifying all method names in a class, this could result in a lot of logged calls.

 

Hopefully this will give a basic understanding of the Trace logging which is a very powerful tool when debugging Maximo.

 

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSLKT6","label":"IBM Maximo Asset Management"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

UID

ibm11130973