Friday, October 31, 2014

How Verify the developed MEC Mapper using MEC Loggers

In this post, I'm going to describe two ways that I've used to verify the mapper logic that I have implemented using the mapper diagrams and behind code. This is not about the debugging option that is discussed in the "M3 Enterprise Collaborator Mapping Manager User Guide".

As a best practice, you can use the build logger options below.
ALL LOGGING 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 costs resulting to drain on the performance of the 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 and set it to false when moving to production.

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

My advice is to always use a specific prefix at the start of your comment text to make them locate 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" );   

There are two ways to check this logged information.

1. Using the Infor LifeCycle Manager

First logged in to LifeCycle Manager, and expand the M3 Enterprise Collaborator x.x.x.x.

Then right click on MEC and select Manage Application.



Click on Events


This view shows only the last 500 events recorded.


The disadvantage in here is that you can only view the last 500 events (by default), you can specify a time frame, part of the text message, etc. by using the Log search option.

2. Using the MEC Storage Database
To use this method, you have to have permission to access the database server. 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 to use SQL Management Studio.  Use the below query to list the events recorded.

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

You can build the query by directly executing this query.

declare @query as varchar(512)
declare @maxValue as bigint
select @maxValue= max(LogTime) from MecLog

select @query='select  LogTime, Message
from dbo.MecLog
where LogTime >'+ 
convert(varchar(30),@maxValue) +'order by LogTime ASC'
select @query


The advantage in here is that you can get all the events, and you have the power of using SQL to filter-out the result.

1 comment: