Five Stars

log4j to a file

Hi, 
I need help to write log4j logging information to a file. By default log4J is writing on console. How should I configure, and where should I configure If I want log4J to write logging information to a file like " c:/log.txt ".

 
Thanks,
Abhi529

  • Data Integration
4 REPLIES
Moderator

Re: log4j to a file

Hello,

Please take a look at this related topic:https://community.talend.com/t5/Design-and-Development/Issue-with-tRest/m-p/31782

You can do this with a little Java code in a tJava component at the beginning of your Job or use a custom component tredirectOutput.

Let us know if it is Ok with you.

Best regards

Sabrina

 

 

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: log4j to a file

Hi xdshi,

thanks for your answer but it is not work for me.

I have added the following code into log4j.xml.....then still i am unable to get the the log4j file in reqired location...

 <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>

Please find below image...

Capture_log4j.JPG

Thanks,

Abhi529

Tags (1)
Moderator

Re: log4j to a file

Hi,

You added code into log4j.xml?

Have you tried to use this custom component tredirectoutput which is used to redirect all the message printed on the console to a file. to see if it works?

Best regards

Sabrina

 

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Moderator

Re: log4j to a file

Hello,

Is there any update for your issue? Feel free to post your issue here.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.