<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article Qlik Talend Studio: Log4j Tips and Tricks in Official Support Articles</title>
    <link>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Talend-Studio-Log4j-Tips-and-Tricks/ta-p/2151296</link>
    <description>&lt;P&gt;Log4j, incorporated in Talend software, is an essential tool for discovering and solving problems. This article shows you some tips and tricks for using Log4j.&lt;/P&gt;
&lt;P&gt;The examples in this article use Log4j v1, but Talend 7.3 uses Log4j v2. Although the syntax is different between the versions, anything you do in Log4j v1 should work, with some modification, in Log4j v2. For more information on Log4j v2, see &lt;A href="https://help.talend.com/reader/9TuKg6zZZmEHit1Ntl3pOw/2kpRuWQFjIGun6Lj6H31ww" target="_blank" rel="noopener"&gt;Configuring Log4j&lt;/A&gt;, available in the Talend Help Center.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Content:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-TOC indent="15" liststyle="none" maxheadinglevel="4"&gt;&lt;/LI-TOC&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Configuring Log4j in Talend Studio&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;Configure the &lt;STRONG&gt;log4j.xml&lt;/STRONG&gt; file in Talend Studio by navigating to &lt;STRONG&gt;File&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Edit Project properties&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Log4j&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="configuring log4j in talend studio.gif" style="width: 798px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125905iFD66566E8BB663A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="configuring log4j in talend studio.gif" alt="configuring log4j in talend studio.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can also configure Log4j using properties files or built-in classes; however, that is not covered in this article.&lt;/P&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Emitting messages&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H4&gt;
&lt;P&gt;You can execute code in a &lt;STRONG&gt;tJava&lt;/STRONG&gt; component to create Log4j messages, as shown in the example below:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;log.info("Hello World");
log.warn("HELLO WORLD!!!");&lt;/PRE&gt;
&lt;P&gt;This code results in the following messages:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;[INFO ]: myproject.myjob - Hello World
[WARN ]: myproject.myjob - HELLO WORLD!!!&lt;/PRE&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Routines&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;You can use Log4j to emit messages by creating a logger class in a routine, as shown in the example below:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;public class logSample {
/*Pick 1 that fits*/
	private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(logSample.class);
	private static org.apache.log4j.Logger log1 = org.apache.log4j.Logger.getLogger("from_routine_logSample");
 /*...*/
   public static void helloExample(String message) {
        if (message == null) {
            message = "World"; 
        }
        log.info("Hello " + message + " !");
        log1.info("Hello " + message + " !");
    }
}&lt;/PRE&gt;
&lt;P&gt;To call this routine from Talend, use the following command in a &lt;STRONG&gt;tJava&lt;/STRONG&gt; component:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;logSample.helloExample("Talend");&lt;/PRE&gt;
&lt;P&gt;The log results will look like this:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;[INFO ]: routines.logSample - Hello Talend !
[INFO ]: from_routine_logSample - Hello Talend !&lt;/PRE&gt;
&lt;P&gt;Using &lt;STRONG&gt;&lt;EM&gt;&amp;lt;routineName&amp;gt;&lt;/EM&gt;.class&lt;/STRONG&gt; includes the class name in the log results. Using free text with the logger includes the text itself in the log results. This is not really different than using &lt;STRONG&gt;System.out&lt;/STRONG&gt;, but Log4j can be customized and fine-tuned.&lt;/P&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Controlling Log4j message formats with patterns&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;You can use patterns to control the Log4j message format. Adding patterns to Appenders customizes their output. Patterns add extra information to the message itself. For example, when multiple threads are used, the default pattern doesn't provide information about the origin of the message. Use the &lt;STRONG&gt;%t&lt;/STRONG&gt; variable to add a thread name to the logs. To easily identify new messages, it's helpful to use &lt;STRONG&gt;%d&lt;/STRONG&gt; to add a timestamp to the log message.&lt;/P&gt;
&lt;P&gt;To add thread names and timestamps, use the following pattern after the &lt;STRONG&gt;CONSOLE appender&lt;/STRONG&gt; section in the Log4j template:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;&amp;lt;param name="ConversionPattern"  		  		
       value= "%d{yyyy-MM-dd HH:mm:ss}  [%-5p] (%t): %c - %m%n" /&amp;gt;&lt;/PRE&gt;
&lt;P&gt;The pattern displays messages as follows:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;ISO formatted date [log level] (thread name): class projectname.jobname - message contents&lt;/PRE&gt;
&lt;P&gt;If the following Java code is executed in three parallel threads, using the sample pattern above helps distinguish between the threads.&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;java.util.Random rand = new java.util.Random();
log.info("Hello World");
Thread.sleep(rand.nextInt(1000));
log.warn("HELLO WORLD!!!");
logSample.helloExample("Talend");&lt;/PRE&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="parallelize.png" style="width: 232px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125906iC679D7384333F0E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="parallelize.png" alt="parallelize.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This results in an output that shows which thread emitted the message and when:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;2020-05-19 12:18:30  [INFO ] (tParallelize_1_e45bc79b-d61f-45a3-be8f-7089ab6d565d): myproject.myjob_0_1.myjob - Hello World
2020-05-19 12:18:30  [INFO ] (tParallelize_1_4064c9b8-0585-41e0-b9f0-95fb31e602b7): myproject.myjob_0_1.myjob - Hello World
2020-05-19 12:18:30  [INFO ] (tParallelize_1_a8ef1065-0106-4b45-8a60-d02a9cbe1f00): myproject.myjob_0_1.myjob - Hello World
2020-05-19 12:18:30  [WARN ] (tParallelize_1_e45bc79b-d61f-45a3-be8f-7089ab6d565d): myproject.myjob_0_1.myjob - HELLO WORLD!!!
2020-05-19 12:18:30  [INFO ] (tParallelize_1_e45bc79b-d61f-45a3-be8f-7089ab6d565d): routines.logSample - Hello Talend !
2020-05-19 12:18:30  [INFO ] (tParallelize_1_e45bc79b-d61f-45a3-be8f-7089ab6d565d): from_routine.logSample - Hello Talend !
2020-05-19 12:18:30  [WARN ] (tParallelize_1_a8ef1065-0106-4b45-8a60-d02a9cbe1f00): myproject.myjob_0_1.myjob - HELLO WORLD!!!
2020-05-19 12:18:30  [INFO ] (tParallelize_1_a8ef1065-0106-4b45-8a60-d02a9cbe1f00): routines.logSample - Hello Talend !
2020-05-19 12:18:30  [INFO ] (tParallelize_1_a8ef1065-0106-4b45-8a60-d02a9cbe1f00): from_routine.logSample - Hello Talend !
2020-05-19 12:18:31  [WARN ] (tParallelize_1_4064c9b8-0585-41e0-b9f0-95fb31e602b7): myproject.myjob_0_1.myjob - HELLO WORLD!!!
2020-05-19 12:18:31  [INFO ] (tParallelize_1_4064c9b8-0585-41e0-b9f0-95fb31e602b7): routines.logSample - Hello Talend !
2020-05-19 12:18:31  [INFO ] (tParallelize_1_4064c9b8-0585-41e0-b9f0-95fb31e602b7): from_routine.logSample - Hello Talend !&lt;/PRE&gt;
&lt;P&gt;If you want to know which component belongs to which thread, you need to change the log level to add more information.&lt;/P&gt;
&lt;P&gt;You can do this in Studio on the &lt;STRONG&gt;Run&lt;/STRONG&gt; tab, in the &lt;STRONG&gt;Advanced settings&lt;/STRONG&gt; tab of the Job execution.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="advanced settings of job execution.gif" style="width: 798px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125907i26C2D9B7BFAEDF90/image-size/large?v=v2&amp;amp;px=999" role="button" title="advanced settings of job execution.gif" alt="advanced settings of job execution.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In Talend Administration Center, you do this in Job Conductor.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job conductor.gif" style="width: 394px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125908i70A2B5287BDA0F37/image-size/large?v=v2&amp;amp;px=999" role="button" title="job conductor.gif" alt="job conductor.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Using DEBUG level adds a few extra lines to the log file, which can help you understand which parameters resulted in a certain output:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;2020-05-19 12:51:50  [DEBUG] (tParallelize_1_c6de81be-1bbf-4f9b-9b7a-3d92bf345c40): myproject.myjob_0_1.myjob - tParallelize_1 - The subjob starting with the component 'tJava_1' starts.
2020-05-19 12:51:50  [DEBUG] (tParallelize_1_fa636a36-9f53-423f-abc6-b26c4c52c5b4): myproject.myjob_0_1.myjob - tParallelize_1 - The subjob starting with the component 'tJava_3' starts.
2020-05-19 12:51:50  [DEBUG] (tParallelize_1_d4da8ea0-4401-4229-82e9-86ff0ed67c3b): myproject.myjob_0_1.myjob - tParallelize_1 - The subjob starting with the component 'tJava_2' starts.&lt;/PRE&gt;
&lt;P&gt;Keep in mind the following:&lt;/P&gt;
&lt;UL class="lia-list-style-type-circle"&gt;
&lt;LI&gt;Changing the default log pattern causes Studio to stop coloring the messages.&lt;/LI&gt;
&lt;LI&gt;The default log level in Studio is defined by the root logger's priority value (&lt;STRONG&gt;Warn&lt;/STRONG&gt;, by default).&lt;/LI&gt;
&lt;LI&gt;Changing the log level changes the number of messages.&lt;/LI&gt;
&lt;LI&gt;Changing the pattern changes the message format.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Logging levels&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;The following table describes the Log4j logging levels you can use in Talend applications:&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;&lt;STRONG&gt;Debug Level&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;TRACE&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;Everything that is available is being emitted at this logging level, which makes every row behave like it has a &lt;STRONG&gt;tLogRow&lt;/STRONG&gt; component attached. This can make the log file extremely large; however, it also displays the transformation done by each component.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;DEBUG&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;This logging level displays the component parameters, database connection information, queries executed, and provides information about which row is processed, but it does not capture the actual data.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;INFO&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;This logging level includes the Job start and finish times, and how many records were read and written.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;WARN&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;Talend components do not use this logging level.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;ERROR&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;This logging level writes exceptions. These exceptions do not necessarily cause the Job to halt.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;FATAL&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;When this appears, the Job execution is halted.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;OFF&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;Nothing is emitted.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These levels offer high-level controls for messages. When changed from the outside they affect only the Appenders that did not specify a log level and rely on the level set by the root logger.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Using Appenders&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H4&gt;
&lt;P&gt;Log4j messages are processed by Appenders, which route the messages to different outputs, such as to console, files, or logstash. Appenders can even send messages to databases, but for database logs, the built-in Stats &amp;amp; Logs might be a better solution.&lt;/P&gt;
&lt;P&gt;Storing Log4j messages in files can be useful when working with standalone Jobs. Here is an example of a file Appender:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;&amp;lt;appender name="ROLLINGFILE" class="org.apache.log4j.RollingFileAppender"&amp;gt;
  &amp;lt;param name="file" value="rolling_error.log"/&amp;gt;
  &amp;lt;param name="Threshold" value="ERROR"/&amp;gt;
  &amp;lt;param name="MaxFileSize" value="10000KB"/&amp;gt;
  &amp;lt;param name="MaxBackupIndex" value="5"/&amp;gt;
  &amp;lt;layout class="org.apache.log4j.PatternLayout"&amp;gt;
    &amp;lt;param name="ConversionPattern" 
           value="%d{yyyy-MM-dd HH:mm:ss}  [%-5p] (%t): %c - %m%n"/&amp;gt;
  &amp;lt;/layout&amp;gt;
&amp;lt;/appender&amp;gt;&lt;/PRE&gt;
&lt;P&gt;You can use multiple Appenders to have multiple files with different log levels and formats. Use the parameters to control the content. The &lt;STRONG&gt;Threshold&lt;/STRONG&gt; value of &lt;STRONG&gt;ERROR&lt;/STRONG&gt; doesn't provide information about the Job execution, but a value of &lt;STRONG&gt;INFO&lt;/STRONG&gt; makes errors harder to detect.&lt;/P&gt;
&lt;P&gt;For more information on Appenders, see the Apache &lt;A href="https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Appender.html" target="_blank" rel="noopener"&gt;Interface Appender&lt;/A&gt; page.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Using filters&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H4&gt;
&lt;P&gt;You can use filters with Appenders to keep messages that are not of interest out of the logs. Log4j v2 offers regular expression based filters too.&lt;/P&gt;
&lt;P&gt;The following example filter omits any Log4j messages that contain the string &lt;STRONG&gt;" - Adding the record "&lt;/STRONG&gt;.&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;&amp;lt;filter class="org.apache.log4j.varia.StringMatchFilter"&amp;gt;
	&amp;lt;param name="StringToMatch" value=" - Adding the record " /&amp;gt;
	&amp;lt;param name="AcceptOnMatch" value="false" /&amp;gt;
&amp;lt;/filter&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Overriding default settings in Talend Administration Center&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;When a Java program starts, it attempts to load its Log4j settings from the &lt;STRONG&gt;log4j.xml&lt;/STRONG&gt; file. You can modify this file to change the default settings, or you can force Java to use a different file. For example, you can do this for Jobs deployed to Talend Administration Center by configuring the JVM parameters. This way, you can change the logging behavior for a Job without modifying the original Job, or you can revert back to the original logging behavior by clearing the &lt;STRONG&gt;Active&lt;/STRONG&gt; check box.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="overriding default settings in talend.png" style="width: 787px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125909i053C9FF164172E9C/image-size/large?v=v2&amp;amp;px=999" role="button" title="overriding default settings in talend.png" alt="overriding default settings in talend.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Environment&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;LI-PRODUCT title="Talend Studio" id="qlik_TalendStudio"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;LI-PRODUCT title="Talend Administration Center" id="qlik_TalendAdministrationCenter"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Mon, 08 Dec 2025 05:41:00 GMT</pubDate>
    <dc:creator>TalendSolutionExpert</dc:creator>
    <dc:date>2025-12-08T05:41:00Z</dc:date>
    <item>
      <title>Qlik Talend Studio: Log4j Tips and Tricks</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Talend-Studio-Log4j-Tips-and-Tricks/ta-p/2151296</link>
      <description>&lt;P&gt;Log4j, incorporated in Talend software, is an essential tool for discovering and solving problems. This article shows you some tips and tricks for using Log4j.&lt;/P&gt;
&lt;P&gt;The examples in this article use Log4j v1, but Talend 7.3 uses Log4j v2. Although the syntax is different between the versions, anything you do in Log4j v1 should work, with some modification, in Log4j v2. For more information on Log4j v2, see &lt;A href="https://help.talend.com/reader/9TuKg6zZZmEHit1Ntl3pOw/2kpRuWQFjIGun6Lj6H31ww" target="_blank" rel="noopener"&gt;Configuring Log4j&lt;/A&gt;, available in the Talend Help Center.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Content:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-TOC indent="15" liststyle="none" maxheadinglevel="4"&gt;&lt;/LI-TOC&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Configuring Log4j in Talend Studio&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;Configure the &lt;STRONG&gt;log4j.xml&lt;/STRONG&gt; file in Talend Studio by navigating to &lt;STRONG&gt;File&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Edit Project properties&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Log4j&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="configuring log4j in talend studio.gif" style="width: 798px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125905iFD66566E8BB663A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="configuring log4j in talend studio.gif" alt="configuring log4j in talend studio.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can also configure Log4j using properties files or built-in classes; however, that is not covered in this article.&lt;/P&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Emitting messages&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H4&gt;
&lt;P&gt;You can execute code in a &lt;STRONG&gt;tJava&lt;/STRONG&gt; component to create Log4j messages, as shown in the example below:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;log.info("Hello World");
log.warn("HELLO WORLD!!!");&lt;/PRE&gt;
&lt;P&gt;This code results in the following messages:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;[INFO ]: myproject.myjob - Hello World
[WARN ]: myproject.myjob - HELLO WORLD!!!&lt;/PRE&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Routines&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;You can use Log4j to emit messages by creating a logger class in a routine, as shown in the example below:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;public class logSample {
/*Pick 1 that fits*/
	private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(logSample.class);
	private static org.apache.log4j.Logger log1 = org.apache.log4j.Logger.getLogger("from_routine_logSample");
 /*...*/
   public static void helloExample(String message) {
        if (message == null) {
            message = "World"; 
        }
        log.info("Hello " + message + " !");
        log1.info("Hello " + message + " !");
    }
}&lt;/PRE&gt;
&lt;P&gt;To call this routine from Talend, use the following command in a &lt;STRONG&gt;tJava&lt;/STRONG&gt; component:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;logSample.helloExample("Talend");&lt;/PRE&gt;
&lt;P&gt;The log results will look like this:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;[INFO ]: routines.logSample - Hello Talend !
[INFO ]: from_routine_logSample - Hello Talend !&lt;/PRE&gt;
&lt;P&gt;Using &lt;STRONG&gt;&lt;EM&gt;&amp;lt;routineName&amp;gt;&lt;/EM&gt;.class&lt;/STRONG&gt; includes the class name in the log results. Using free text with the logger includes the text itself in the log results. This is not really different than using &lt;STRONG&gt;System.out&lt;/STRONG&gt;, but Log4j can be customized and fine-tuned.&lt;/P&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Controlling Log4j message formats with patterns&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;You can use patterns to control the Log4j message format. Adding patterns to Appenders customizes their output. Patterns add extra information to the message itself. For example, when multiple threads are used, the default pattern doesn't provide information about the origin of the message. Use the &lt;STRONG&gt;%t&lt;/STRONG&gt; variable to add a thread name to the logs. To easily identify new messages, it's helpful to use &lt;STRONG&gt;%d&lt;/STRONG&gt; to add a timestamp to the log message.&lt;/P&gt;
&lt;P&gt;To add thread names and timestamps, use the following pattern after the &lt;STRONG&gt;CONSOLE appender&lt;/STRONG&gt; section in the Log4j template:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;&amp;lt;param name="ConversionPattern"  		  		
       value= "%d{yyyy-MM-dd HH:mm:ss}  [%-5p] (%t): %c - %m%n" /&amp;gt;&lt;/PRE&gt;
&lt;P&gt;The pattern displays messages as follows:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;ISO formatted date [log level] (thread name): class projectname.jobname - message contents&lt;/PRE&gt;
&lt;P&gt;If the following Java code is executed in three parallel threads, using the sample pattern above helps distinguish between the threads.&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;java.util.Random rand = new java.util.Random();
log.info("Hello World");
Thread.sleep(rand.nextInt(1000));
log.warn("HELLO WORLD!!!");
logSample.helloExample("Talend");&lt;/PRE&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="parallelize.png" style="width: 232px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125906iC679D7384333F0E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="parallelize.png" alt="parallelize.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This results in an output that shows which thread emitted the message and when:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;2020-05-19 12:18:30  [INFO ] (tParallelize_1_e45bc79b-d61f-45a3-be8f-7089ab6d565d): myproject.myjob_0_1.myjob - Hello World
2020-05-19 12:18:30  [INFO ] (tParallelize_1_4064c9b8-0585-41e0-b9f0-95fb31e602b7): myproject.myjob_0_1.myjob - Hello World
2020-05-19 12:18:30  [INFO ] (tParallelize_1_a8ef1065-0106-4b45-8a60-d02a9cbe1f00): myproject.myjob_0_1.myjob - Hello World
2020-05-19 12:18:30  [WARN ] (tParallelize_1_e45bc79b-d61f-45a3-be8f-7089ab6d565d): myproject.myjob_0_1.myjob - HELLO WORLD!!!
2020-05-19 12:18:30  [INFO ] (tParallelize_1_e45bc79b-d61f-45a3-be8f-7089ab6d565d): routines.logSample - Hello Talend !
2020-05-19 12:18:30  [INFO ] (tParallelize_1_e45bc79b-d61f-45a3-be8f-7089ab6d565d): from_routine.logSample - Hello Talend !
2020-05-19 12:18:30  [WARN ] (tParallelize_1_a8ef1065-0106-4b45-8a60-d02a9cbe1f00): myproject.myjob_0_1.myjob - HELLO WORLD!!!
2020-05-19 12:18:30  [INFO ] (tParallelize_1_a8ef1065-0106-4b45-8a60-d02a9cbe1f00): routines.logSample - Hello Talend !
2020-05-19 12:18:30  [INFO ] (tParallelize_1_a8ef1065-0106-4b45-8a60-d02a9cbe1f00): from_routine.logSample - Hello Talend !
2020-05-19 12:18:31  [WARN ] (tParallelize_1_4064c9b8-0585-41e0-b9f0-95fb31e602b7): myproject.myjob_0_1.myjob - HELLO WORLD!!!
2020-05-19 12:18:31  [INFO ] (tParallelize_1_4064c9b8-0585-41e0-b9f0-95fb31e602b7): routines.logSample - Hello Talend !
2020-05-19 12:18:31  [INFO ] (tParallelize_1_4064c9b8-0585-41e0-b9f0-95fb31e602b7): from_routine.logSample - Hello Talend !&lt;/PRE&gt;
&lt;P&gt;If you want to know which component belongs to which thread, you need to change the log level to add more information.&lt;/P&gt;
&lt;P&gt;You can do this in Studio on the &lt;STRONG&gt;Run&lt;/STRONG&gt; tab, in the &lt;STRONG&gt;Advanced settings&lt;/STRONG&gt; tab of the Job execution.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="advanced settings of job execution.gif" style="width: 798px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125907i26C2D9B7BFAEDF90/image-size/large?v=v2&amp;amp;px=999" role="button" title="advanced settings of job execution.gif" alt="advanced settings of job execution.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In Talend Administration Center, you do this in Job Conductor.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job conductor.gif" style="width: 394px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125908i70A2B5287BDA0F37/image-size/large?v=v2&amp;amp;px=999" role="button" title="job conductor.gif" alt="job conductor.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Using DEBUG level adds a few extra lines to the log file, which can help you understand which parameters resulted in a certain output:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;2020-05-19 12:51:50  [DEBUG] (tParallelize_1_c6de81be-1bbf-4f9b-9b7a-3d92bf345c40): myproject.myjob_0_1.myjob - tParallelize_1 - The subjob starting with the component 'tJava_1' starts.
2020-05-19 12:51:50  [DEBUG] (tParallelize_1_fa636a36-9f53-423f-abc6-b26c4c52c5b4): myproject.myjob_0_1.myjob - tParallelize_1 - The subjob starting with the component 'tJava_3' starts.
2020-05-19 12:51:50  [DEBUG] (tParallelize_1_d4da8ea0-4401-4229-82e9-86ff0ed67c3b): myproject.myjob_0_1.myjob - tParallelize_1 - The subjob starting with the component 'tJava_2' starts.&lt;/PRE&gt;
&lt;P&gt;Keep in mind the following:&lt;/P&gt;
&lt;UL class="lia-list-style-type-circle"&gt;
&lt;LI&gt;Changing the default log pattern causes Studio to stop coloring the messages.&lt;/LI&gt;
&lt;LI&gt;The default log level in Studio is defined by the root logger's priority value (&lt;STRONG&gt;Warn&lt;/STRONG&gt;, by default).&lt;/LI&gt;
&lt;LI&gt;Changing the log level changes the number of messages.&lt;/LI&gt;
&lt;LI&gt;Changing the pattern changes the message format.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Logging levels&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;The following table describes the Log4j logging levels you can use in Talend applications:&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;&lt;STRONG&gt;Debug Level&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;TRACE&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;Everything that is available is being emitted at this logging level, which makes every row behave like it has a &lt;STRONG&gt;tLogRow&lt;/STRONG&gt; component attached. This can make the log file extremely large; however, it also displays the transformation done by each component.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;DEBUG&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;This logging level displays the component parameters, database connection information, queries executed, and provides information about which row is processed, but it does not capture the actual data.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;INFO&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;This logging level includes the Job start and finish times, and how many records were read and written.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;WARN&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;Talend components do not use this logging level.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;ERROR&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;This logging level writes exceptions. These exceptions do not necessarily cause the Job to halt.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;FATAL&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;When this appears, the Job execution is halted.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="1" rowspan="1" width="85px"&gt;OFF&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" width="1005px"&gt;Nothing is emitted.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These levels offer high-level controls for messages. When changed from the outside they affect only the Appenders that did not specify a log level and rely on the level set by the root logger.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Using Appenders&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H4&gt;
&lt;P&gt;Log4j messages are processed by Appenders, which route the messages to different outputs, such as to console, files, or logstash. Appenders can even send messages to databases, but for database logs, the built-in Stats &amp;amp; Logs might be a better solution.&lt;/P&gt;
&lt;P&gt;Storing Log4j messages in files can be useful when working with standalone Jobs. Here is an example of a file Appender:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;&amp;lt;appender name="ROLLINGFILE" class="org.apache.log4j.RollingFileAppender"&amp;gt;
  &amp;lt;param name="file" value="rolling_error.log"/&amp;gt;
  &amp;lt;param name="Threshold" value="ERROR"/&amp;gt;
  &amp;lt;param name="MaxFileSize" value="10000KB"/&amp;gt;
  &amp;lt;param name="MaxBackupIndex" value="5"/&amp;gt;
  &amp;lt;layout class="org.apache.log4j.PatternLayout"&amp;gt;
    &amp;lt;param name="ConversionPattern" 
           value="%d{yyyy-MM-dd HH:mm:ss}  [%-5p] (%t): %c - %m%n"/&amp;gt;
  &amp;lt;/layout&amp;gt;
&amp;lt;/appender&amp;gt;&lt;/PRE&gt;
&lt;P&gt;You can use multiple Appenders to have multiple files with different log levels and formats. Use the parameters to control the content. The &lt;STRONG&gt;Threshold&lt;/STRONG&gt; value of &lt;STRONG&gt;ERROR&lt;/STRONG&gt; doesn't provide information about the Job execution, but a value of &lt;STRONG&gt;INFO&lt;/STRONG&gt; makes errors harder to detect.&lt;/P&gt;
&lt;P&gt;For more information on Appenders, see the Apache &lt;A href="https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Appender.html" target="_blank" rel="noopener"&gt;Interface Appender&lt;/A&gt; page.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Using filters&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H4&gt;
&lt;P&gt;You can use filters with Appenders to keep messages that are not of interest out of the logs. Log4j v2 offers regular expression based filters too.&lt;/P&gt;
&lt;P&gt;The following example filter omits any Log4j messages that contain the string &lt;STRONG&gt;" - Adding the record "&lt;/STRONG&gt;.&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;&amp;lt;filter class="org.apache.log4j.varia.StringMatchFilter"&amp;gt;
	&amp;lt;param name="StringToMatch" value=" - Adding the record " /&amp;gt;
	&amp;lt;param name="AcceptOnMatch" value="false" /&amp;gt;
&amp;lt;/filter&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;Overriding default settings in Talend Administration Center&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;When a Java program starts, it attempts to load its Log4j settings from the &lt;STRONG&gt;log4j.xml&lt;/STRONG&gt; file. You can modify this file to change the default settings, or you can force Java to use a different file. For example, you can do this for Jobs deployed to Talend Administration Center by configuring the JVM parameters. This way, you can change the logging behavior for a Job without modifying the original Job, or you can revert back to the original logging behavior by clearing the &lt;STRONG&gt;Active&lt;/STRONG&gt; check box.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="overriding default settings in talend.png" style="width: 787px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/125909i053C9FF164172E9C/image-size/large?v=v2&amp;amp;px=999" role="button" title="overriding default settings in talend.png" alt="overriding default settings in talend.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Environment&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;LI-PRODUCT title="Talend Studio" id="qlik_TalendStudio"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;LI-PRODUCT title="Talend Administration Center" id="qlik_TalendAdministrationCenter"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 08 Dec 2025 05:41:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Talend-Studio-Log4j-Tips-and-Tricks/ta-p/2151296</guid>
      <dc:creator>TalendSolutionExpert</dc:creator>
      <dc:date>2025-12-08T05:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j tips and tricks</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Talend-Studio-Log4j-Tips-and-Tricks/tac-p/2454113#M13967</link>
      <description>&lt;P&gt;this may be out of date with regards to Log4j2, as when I try to use the filter example, I get:&lt;BR /&gt;main ERROR Console contains an invalid element or attribute "filter"&lt;/P&gt;
&lt;P&gt;And if I change it to "Filters", mentioned in the official Log4j documentation (&lt;A href="https://logging.apache.org/log4j/2.x/manual/filters.html" target="_self"&gt;https://logging.apache.org/log4j/2.x/manual/filters.html&lt;/A&gt;), I get:&lt;/P&gt;
&lt;P&gt;main ERROR Filters contains invalid attributes "param", "class"&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 09:28:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Talend-Studio-Log4j-Tips-and-Tricks/tac-p/2454113#M13967</guid>
      <dc:creator>MDouglas1687874333</dc:creator>
      <dc:date>2024-05-20T09:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j tips and tricks</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Talend-Studio-Log4j-Tips-and-Tricks/tac-p/2454194#M13971</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/273124"&gt;@MDouglas1687874333&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your suggestion and feedback. We will make an investigation on it and then come back to you as soon as we can.&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Sabrina&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 12:36:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Talend-Studio-Log4j-Tips-and-Tricks/tac-p/2454194#M13971</guid>
      <dc:creator>Xiaodi_Shi</dc:creator>
      <dc:date>2024-05-20T12:36:11Z</dc:date>
    </item>
  </channel>
</rss>

