cancel
Showing results for 
Search instead for 
Did you mean: 

Add trace and audit log using UDF / JAVA Mapping

itabhishek9
Participant
0 Kudos

Hi SDNites,

I am looking to add

a. trace

b. audit log using,

1. UDF

2. JAVA Mapping.

Can you please give me sample example to implement the same.

Regards,

Abhi

Accepted Solutions (1)

Accepted Solutions (1)

RaghuVamseedhar
Active Contributor
0 Kudos

Abhishek,

Container

1. To add trace in UDF - sample code,


  public String calculate(Container container) throws StreamTransformationException {

        container.getTrace().addDebugMessage("Message to  Trace");

        return "Sum of numbers";      

    }

2. To add trace in Java Mapping

getTrace().addDebugMessage("Message to Trace"); 

Check code here

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Raghu,

Adding to what you've said, there are two more methods for traces.

addInfo("String");

addWarning("String");

addDebugMessage can't be seen when using displayQueue e.g

In test tab, setting trace level to debug will display ALL traces

Setting trace to Info will ONLY display addInfo and addWarning messages.

Setting trace to Warning will ONLY display addWarning messages.

Take note that the ability of the system to display the trace messages at runtime ultimately depends on the configuration in sxmb_adm -> integration engine configuration -> specific configuration -> trace level (not sure about single stack).

setting it to 3 = setting the trace to debug

setting it to 2 = setting the trace to info

setting it to 1 = setting the trace to warning.

Auditlog traces can only be added via adapter module.

Regards,

Mark

Former Member
0 Kudos

refer this for SIngle stack

Answers (2)

Answers (2)

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Abhishek,

If you query has been answered, then can you please close this thread.

itabhishek9
Participant
0 Kudos

Thanks for your responses.

I understand the usage of addInfo and addWarning. Can you please let me know what is the use of addDebugMessage.

Usage of the above traces messages is only to track any error in PRD. Also we can put these messages at the points which will help us in understanding the last success record so we can identify the correct record which is creating the problem. Please correct me if I am wrong.

Also if there is a sample scenario displaying the use of above parameters efficiently if it will be of much help.

Regards,

Abhi

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Abhishek,

If we add DebugMessage(some text) in the udf and when you execute the mapping part with some test data. Then you can find that information in the logs in the trace level(option Debug) of the execution happened.

The marked one is the text which i have written in the trace.addDebugMessage() in the udf.


Even you don't have any text using trace object in the udf, if you jsut select the relevant trace level options at the trace in the test tab, it just shows the action pertaining to the trace level and displays the same in the pop up window when you test with a test data.



If you select the level Debug in the trace, then it's just like when you debug any code, you will just traverse through each line, it is the same way here. Normally we won't use this method of the trace frequently until and unless there is a need to go.


Just play around these and you can explore yourself on this.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Abhishek,

If you want to trace in production use the addWarning since it is considered as level 1 trace and consumes less overhead than addInfo and addDebugMessage. Well anyway, in prod you'll rarely see a system use a trace level higher than 1 because of resource consumption.

Regards,

Mark