Example 3: Logs

If you can't play the video, make sure that you are logged in at Wex Solutions.

This example demonstrates how to incorporate logging into the WEX's code. Logging can be turned on and off and logs can be downloaded from the Extension Manager. If you want to learn more about logging, make sure you check out the Development section of the Developer Guide.

You can find the code for this example in our GitHub repository.

Implementation

You can find the code that includes the logging in this file:

com/wincomplm/wex/example/log/methods/ExampleMethods.java

As you will see, there are several types of log entry:

    logger.error("Will always appear, for serious errors {0}", anObjectWithToString);
    logger.warn("Something we want to know about {0}", anObjectWithToString);

    logger.info("Used to give information on data {0}", anObjectWithToString);

    // Debug and trace only appear if the extension logging is enabled in the manager
    logger.debug("Used to give information on executiom {0}", anObjectWithToString);

The different types of logging are meant to be used with a purpose. They differ in their way of being enabled and the locations in which they appear:

Log type Enable via action Appears on Method Server Description
error false true Indicates a serious error, normally put into caught exceptions.
warn false true Provide information on anomalous events.
info true true General information that show interesting data.
debug true false Debug messages.
trace true false Used to mark entry and exit points of methods.

Execution

The testing is done from a link located in the WEX's User Guide, which can be accessed from the Extension Manager:

1617685902514

It will use a simple JSP to run the test. The error and warn messages will appear in the Method Server logs:

1617686418332

Now try turning the WEX's logging on through the Extension Manager:

1617686355251

This will make the info messages pop up on the Method Server too:

1617686080699

You can also download the logs from the Manager:

1617686537033

1617686618526

The wex-example-log file will contain the trace type logs, which were not displayed on the Method Server.

2021-04-06 05:01:00 ERROR com.wincomplm.wex-example-log.ExampleMethods - Will always appear, for serious errors My object
2021-04-06 05:01:00 WARN  com.wincomplm.wex-example-log.ExampleMethods - Something we want to know about My object
2021-04-06 05:01:00 INFO  com.wincomplm.wex-example-log.ExampleMethods - Used to give information on data My object
2021-04-06 05:01:00 DEBUG com.wincomplm.wex-example-log.ExampleMethods - Used to give information on executiom My object
2021-04-06 05:01:00 TRACE com.wincomplm.wex-example-log.ExampleMethods - =>exampleTrace An argument
2021-04-06 05:01:00 TRACE com.wincomplm.wex-example-log.ExampleMethods - <=exampleTrace Done!