One Star

Logging in Talend.

Hi,
I'm currently using tLogCatcher to catch errors to file. I want to be use log4j to create logs because I want to be able to rotate the log.
I've looked into using tLog4J but I can't seem to understand how to use it and define a properties file for it. Can tLogCatcher in some combination be used to rotate log? how can I use tLog4J for this?
9 REPLIES
Community Manager

Re: Logging in Talend.

Hi
tLog4j should be used with tLog4jCatcher and tInitLog4j together, here is an example job shared by bcourtine on Talend exchange.
http://www.talendforge.org/exchange/index.php?eid=214&product=tos&action=view&nav=1,1,1

Best regard
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Logging in Talend.

There is components in 4.2.2. the tLog4J is self contained.
One Star

Re: Logging in Talend.

Hi, can any one tell me the path to file where the logs are located when we use tlog4j component?
Community Manager

Re: Logging in Talend.

Hi
The path of logs file is defined in the log4j.xml file, and you need to specify the path of log4j.xml file on the tInitLog4j component.
	<appender name="DailyFileAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<param name="File" value="d:/file/test/logs_test.log"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p %c{2} - %m%n"/>
</layout>
</appender>

You can find an example job that using log4j components on Talend Exchange.
http://www.talendforge.org/exchange/index.php?eid=214&product=tos&action=view&nav=1,1,1
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: Logging in Talend.

hello,
 I work on version 5.5.1 and I am using the component tlog4j but I do not know how to download ?
thank you for your help

Community Manager

Re: Logging in Talend.

hello,
 I work on version 5.5.1 and I am using the component tlog4j but I do not know how to download ?
thank you for your help



Please read this KB article how to install a custom component into Talend Studio.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: Logging in Talend.

tLog4j working fine when i run my job from Talend, but it not work when i call my job from eclipse. do you have any clue?
One Star

Re: Logging in Talend.

you have to create web project and add configuration of log4j into web.xml as following
<!-- LOG4J Configuration -->
    <context-param>
        <param-name>log4jConfigLocation</param-name>
<!-- Specify path of log4j properties -->
        <param-value>file:${automation.prop.folder}/TALEND_PROPERTIES/log4j.xml</param-value>
    </context-param>
    <listener>
        <listener-class>
            org.springframework.web.util.IntrospectorCleanupListener 
        </listener-class>
    </listener>
    <listener>
        <listener-class>
            org.springframework.web.util.Log4jConfigListener
        </listener-class>
    </listener>
    <!-- //LOG4J Configuration -->
One Star

Re: Logging in Talend.

Hello Ppl,
can we change the log4j.xml file to get the Error log output in a file instead of console ?
If Yes, could you please tell me how.

Thanks,
Abhijit