When building Integration Actions or Jobs in the Studio, you can use the
tJobLog, tJobFailure and
tLogCatcher components to define log information, collect
exception data and transfer it to the Studio console or to Talend Integration Cloud web
application during execution.
This helps you to analyze and debug the
execution of Integration Action, Jobs or Flows.
Before you begin
- The Log4j option is enabled in the project settings. For further information,
see Talend Studio Developer Guide.
Procedure
-
Open the Integration Action you already defined and drop the
following components from the Palette into
the design workspace: tLogCatcher,
tJobLog (x2) and tJobFailure.
If you have imported the Integration Cloud demo project, you
can drop a ready-to-use exception handling subjob from the Joblets node in the Repository tree view. For further information about the demo
project, see Talend Studio Developer Guide.
-
Link the components together using the Main links.
-
Double-click tLogCatcher component and select the
Catch Java Exception check box in the component
basic settings.
If you use the Joblet from the demo project, this option is selected by
default
-
Double-click the first tJobLog component and
set the following parameters in the component basic settings:
-
Select the Developer option and set the
java expression of the log message in the Log
message field, for example:
"Component: " + row1.origin + "\n | Error type: " + row1.type + "\n
| Error code: " + row1.code + "\n | Error message: " +
row1.message
.
This logs the error messages to the Studio.
-
Select the error type from the Priority
list.
-
Double-click the second tJobLog component and
set the following parameters in the component basic settings:
-
Select the User option
and set the java expression of the log message in the Log message field, for example, row2.message
.
This logs the error messages to the web application.
-
Select the error type from the Priority
list.
-
Double-click tJobFailure and set the following
parameters in the component basic settings:
-
Set Execution failed as the error type
in the Error Type field.
You can define the error type according to your needs and the
value you define in this field will show in the run detail page when you
run a Flow in the Talend Integration Cloud web
application.
-
Set the java expression of the message in the Error Message field.
Example: row3.job + ":" +
row3.origin +": " + row3.message
You can define the error message according to your needs.
For further information about handling logs and exceptions in the
Studio, see the Talend Studio Developer Guide.