tLog4j custom component logging information to a file

One Star

tLog4j custom component logging information to a file

Hi, 
I need help to write tLog4j custom component logging information to a file. By default tLog4J is writing on console. How should I configure, and where should I configure If I want tLog4J to write logging info to a file say " c:/log/myjob.txt ". Help Appreciated. 
Thanks,
Madhu
Community Manager

Re: tLog4j custom component logging information to a file

Hi 
Open the log4j.xml configuration file used in the job and modify the DailyFileAppender attribute, for example:
	<appender name="DailyFileAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<param name="File" value="c:/log/myjob.txt "/>
<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>
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tLog4j custom component logging information to a file

Hi shong,
Thanks for answering.
Where is the log4j.xml in my Job. Are you talking about Log4J setup in Project Settings. ?? Sorry I am new to talend. If you are talking about project setup Log4J, Then please let me know I will delete tLog4J custom component. If not, Their is no log4j.xml file in downloaded extracted tLog4J zip file.
My intention was to use tLog4J custom component. When I use it, by default it is writing logging information on console. I want it to be a on a file and file path should be able to update run time(how we do in regular java web application)
Thanks.
Community Manager

Re: tLog4j custom component logging information to a file

Hi 
I am talking about the Log4j custom components, you can find an example job of log4j components and log4j.xml file from here. In the example job, you need to specify the path of log4j.xml on tInitLog4j component, see
 
Let me know if you can't still make it work.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business