Simple log4j example Job

author
Talend Documentation Team
EnrichVersion
6.5
EnrichProdName
Talend Big Data Platform
Talend Data Fabric
Talend Data Management Platform
Talend Data Services Platform
Talend MDM Platform
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend Studio

Simple log4j example Job

This article is an extracted section of How to activate log4j in Talend Studio? This article presents a simple Job showing how the log4j feature works. The illustrated job reads data from a text file, filters some rows based on a given condition, and finally write the data into a MySQL table.
Environment

This procedure applies to Talend subscription products starting from version 5.0.

Procedure

To create the log4j example Job, proceed as follows:

Adding and linking components
  1. In the Integration perspective of the Studio, create an empty Job. In this example, the Job is called testingLog4j .
  2. In the workspace, enter the name of the component to be used and select this component from the list

    that opens. In this scenario, the components are tFileInputDelimited, tFilterRow and tMysqlOutput.

  3. Connect the components using Row > Main links.
Configuring the components
  1. Double-click the tFileInputDelimited component to open its Basic settings view.
  2. Click the [...] button next to the File Name/Stream field to browse to your input file, D:/work/file/in.csv in this example.

  3. Double-click the tFilterRow component to open its Basic settings view.
  4. In the Conditions table, enter the condition you want to use to filter the data of you input file.

  5. Double-click the tMysqlOutput component to open its Basic settings view.

  6. Enter your connection details in the corresponding fields and, in the Table field, enter the name of the table where you want to store the filtered data.
Saving and executing the Job
  1. Press Ctrl+S to save your Job.
  2. Press F6 to run it.
  3. In D:/ disk, open the testingLog4j.log file. The log messages read as below:
2014-12-19 12:06:55,406 - p1.testinglog4j_0_1.testingLog4j -0    [main] INFO   - TalendJob: 'testingLog4j' - Start.
2014-12-19 12:06:55,431 - p1.testinglog4j_0_1.testingLog4j -25   [main] INFO   - tMysqlOutput_1 - Start to work
2014-12-19 12:06:55,535 - p1.testinglog4j_0_1.testingLog4j -129  [main] INFO   - tMysqlOutput_1 - Connection attempt to 'jdbc:mysql://localhost:3306/test?noDatetimeStringSync=true&rewriteBatchedStatements=true' with the username 'root'.
2014-12-19 12:06:55,609 - p1.testinglog4j_0_1.testingLog4j -203  [main] INFO   - tMysqlOutput_1 - Connection to 'jdbc:mysql://localhost:3306/test?noDatetimeStringSync=true&rewriteBatchedStatements=true' has succeeded.
2014-12-19 12:06:55,611 - p1.testinglog4j_0_1.testingLog4j -205  [main] INFO   - tMysqlOutput_1 - Droping table 'testLog4j'.
2014-12-19 12:06:55,711 - p1.testinglog4j_0_1.testingLog4j -305  [main] INFO   - tMysqlOutput_1 - Drop table 'testLog4j' has succeeded.
2014-12-19 12:06:55,711 - p1.testinglog4j_0_1.testingLog4j -305  [main] INFO   - tMysqlOutput_1 - Creating table 'testLog4j'.
2014-12-19 12:06:55,736 - p1.testinglog4j_0_1.testingLog4j -330  [main] INFO   - tMysqlOutput_1 - Create table 'testLog4j' has succeeded.
2014-12-19 12:06:55,741 - p1.testinglog4j_0_1.testingLog4j -335  [main] INFO   - tFilterRow_1 - Start to work.
2014-12-19 12:06:55,741 - p1.testinglog4j_0_1.testingLog4j -335  [main] INFO   - tFileInputDelimited_1 - Start to work
2014-12-19 12:06:55,744 - p1.testinglog4j_0_1.testingLog4j -338  [main] INFO   - tFileInputDelimited_1 - Retrieving records from the datasource.
2014-12-19 12:06:55,746 - p1.testinglog4j_0_1.testingLog4j -340  [main] INFO   - tFileInputDelimited_1 - Retrieved records count: 7.
2014-12-19 12:06:55,746 - p1.testinglog4j_0_1.testingLog4j -340  [main] INFO   - tFileInputDelimited_1 - Done.
2014-12-19 12:06:55,746 - p1.testinglog4j_0_1.testingLog4j -340  [main] INFO   - tFilterRow_1 - Processed records count:7. Matched records count:4. Rejected records count:3.
2014-12-19 12:06:55,746 - p1.testinglog4j_0_1.testingLog4j -340  [main] INFO   - tFilterRow_1 - Done.
2014-12-19 12:06:55,756 - p1.testinglog4j_0_1.testingLog4j -350  [main] INFO   - tMysqlOutput_1 - Closing the connection to the database.
2014-12-19 12:06:55,756 - p1.testinglog4j_0_1.testingLog4j -350  [main] INFO   - tMysqlOutput_1 - Connection to the database closed.
2014-12-19 12:06:55,756 - p1.testinglog4j_0_1.testingLog4j -350  [main] INFO   - tMysqlOutput_1 - Has inserted 4 records.
2014-12-19 12:06:55,756 - p1.testinglog4j_0_1.testingLog4j -350  [main] INFO   - tMysqlOutput_1 - Done.
2014-12-19 12:06:55,757 - p1.testinglog4j_0_1.testingLog4j -351  [main] INFO   - TalendJob: 'testingLog4j' - Done.