How to enable Log4j level trace when launching a Job on a JobServer from Talend Studio

Talend Version          6.2.1

Summary

How to enable Log4j level trace when launching a Job on a JobServer from Talend Studio.
Additional Versions  
Key words Talend Studio log4j JobServer trace level
Product Talend Data Integration
Component Studio
Article Type Configuration
Problem Description

When executing a job locally from Talend Studio, the log4j trace level can be set in the Run View by clicking the Run tab Advanced settings, then checking the log4jLevel box and choosing the trace level. As a result, the Job log4j messages will be displayed according to the log4j trace level you set for a local Studio Talend job execution.

 

However, when executing a job remotely on a Jobserver from Talend Studio, the log4j messages won't be displayed according to the trace level you set in the Run View. You need to enable the log4j trace to a level so that when launching a job from Talend Studio on a Jobserver, you will be able to see the log4j trace in the Jobserver logs as well as in the local Talend Studio.

Problem root cause  
Solution or Workaround

When a job launched from Talend Studio is executed on a Jobserver, the log4j configuration can be set by performing the following steps in Talend Studio:

  1. Click File > Project properties > Log4j.

  2. Set the trace level in this configuration by changing the priority value:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    
    <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' >
    ....
    <!-- Root Logger -->
    <root>
    <priority value ="trace"/>
    <appender-ref ref="CONSOLE"/>
    <!-- <appender-ref ref="LOGSTASH"/> -->
    </root>
    </log4j:configuration>

    The log4j level here is set to trace level.

  3. Click OK and Save.

When running the job, you should get the trace on the Jobserver with the log4j level set, as well as in Talend Studio Run View.

JIRA ticket number  
Version history
Revision #:
5 of 5
Last update:
‎07-05-2017 01:25 PM
Updated by:
 
Comments
intrilyx

I added a appender to log details of job into a file like below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="Appender1" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-7p %d [%t] %c %x - %m%n"/>
</layout>
</appender>
<appender name="Appender2" class="org.apache.log4j.FileAppender">
<param name="File" value="E:/Ashifapplog.txt" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-7p %d [%t] %c %x - %m%n"/>
</layout>
</appender>
<root>
<priority value="DEBUG"/>
<appender-ref ref="Appender1" />
<appender-ref ref="Appender2" />
</root>
</log4j:configuration>

 

After this log4.xml change, when i run my job . I dont see any log file created . 

 

Do I need to initialize the logger in my job through tjava like below:

 

 org.apache.log4j.Logger logger = Logger.getLogger(jobname.class);

agershenson

Hi ashifa,

If you are still having this problem, please ask your question on one of the discussion forums, or file a support ticket at https://www.talend.com/services/technical-support/.

Hope that helps,

Alyce

intrilyx

Log4j Logging Option is not available in Talend Open Studio.

Otherwise in talend enterprise edition, the above configuration works as expected...