Thursday, October 9, 2014

How to Log and Trace MEC Logs to Verify the Logic

From this post, I'm going to describe two ways that I've used to verify the logic that I have implemented inside of the MEC mapper. This is not the debugging option that is discussed in the "M3 Enterprise Collaborator Mapping Manager User Guide". 

As a best practice you can use the build in logger options as below.


ALL LOGING WITHIN A MAP MAP MUST PREVENT THE USE OF 'System.Out.Println();' AND MUST ONLY USE THE FOLLOWING API'S

cat.info();
cat.warning();
cat.error();
cat.debug();
cat.fatal();
~ M3 Enterprise Collaborator - Best Practices Guide

But, using these loggers unnecessarily will cost some additional I/O cost resulting to drain the performance of the run time server. So it's good to place the logging statements with a boolean flag (initiate a global variable of type boolean) where you can initiate it to true during the development and testing period to enable logging operation.

Ex :
if(debug) {
      cat.info(/*Some comment*/);
}

My advice is to always use a specific prefix as the starting of your comment text to make them locate more faster. So initiate a const string variable and assign a unique value that you can use to identify the map uniquely. For this it's recommended to use the Spec Code, Doc Code, Function Code etc. which is given to you.

as an example :

cat.info( MyMapIdentifier + "Some Comment" ); 

Let's see how to check the logged information.

> Using the Infor LifeCycle Manager
 
1. Logged in to LifeCycle Manager, expand the M3 Enterprise Collaborator x.x.x.x.
2. Right click on MEC and select Manage Application.


3. Click on Events


4. You can view the last 500 events recorded in this window.

   Disadvantage in here is you can use view only the last 500 events (by default), But using the Log search option you can specify a time frame, part of the text message etc. and do an advanced search.

 > Using the MEC Storage Database
You have to have permission to access the database server to use this method. If you are tricky enough, You can locate the login information from the Eclipse (MEC Mapper) preference. Look for the required information inside ION Mapper -> Database Connectivity section.

Then you have to log into the database i.e. if is it Ms-SQL server use SQL Management Studio.  Use the below query to list down the events recorded.

select  LogTime, Message
from dbo.MecLog
where LogTime > 1412853722833
order by LogTime ASC

Before execute this, you have to find the last log time using the same table and set it to the highlighted value. 

Advantage in here is that you can get all the events and you have the power of using the SQL commands.


No comments :

Post a Comment