Sabtu, 19 Juli 2014

Java Logging and Tracing in Maximo

This entry is part of the Maximo Java Development series.

A good logging (tracing) is always a lifesaver when you have problems in a production environment. I will never stop telling to my fellow programmers how much is important to fill code with meaningful log calls.

Maximo has a good and flexible logging subsystem. This IBM TechNote describes in detail how logging works in Maximo. Let's now see hot to use Maximo logging in your custom Java code.

To be able to write entries to the standard Maximo log file you first have to get an instance of psdi.util.logging.MXLogger class. The most common way to achieve this is to use the MXLogger.getLogger(key) method.

The following example describes a typical use of this technique and how to write a log entry in Maximo logs.

public class MyClass extends Mbo implements MboRemote
{
private MXLogger log = MXLoggerFactory.getLogger("maximo.service.WORKORDER");

...

public void sampleMethod()
{
log.info("Log this to INFO level");
...
log.debug("Log this to DEBUG level");
}
}

As you can see, the log attribute can be initialized in the declaration and used in any method.

If you are extending an Mbo, you can retrieve a standard logger calling the psdi.mbo.Mbo.getMboLogger() method. The name of the returned logger be
maximo.service.[service name].[business object name].

public class MyClass extends Mbo implements MboRemote
{
...

public void sampleMethod()
{
getMboLogger().info("This is a log");
}
}


References

Logging in Maximo
Understand Maximo 7.5 logging (IBM Education Assistant)
Understand Maximo 7.5 logging (PDF)


Source:http://maximodev.blogspot.com/2013/05/java-logging-and-tracing-in-maximo.html

Tidak ada komentar:

Posting Komentar