Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
aksharma
Contributor II
Contributor II

log4j2:Providing log file location and log4j.xml configuration file through context variables

Hi

I am migrating from log4j1( 6.2.1) to log42 (7.3.1)

Earlier we used to manually initialize the log4j through tlog4jinit and set the log file name and location through system. set in jobs.

Now we are planning for upgrade and want to use the talend provided log4j2 framework

I see the help document https://help.talend.com/r/9TuKg6zZZmEHit1Ntl3pOw/2kpRuWQFjIGun6Lj6H31ww

Just wanted to check if I can configure something like attach file and set default value for context.logfilename and context.logbasepath variable in the job .Basically I want to provide user to configure the log file name and location.

 

I tried multiple option but nothing is working. Need help

 

Labels (4)
5 Replies
Anonymous
Not applicable

Hello,

Usually, we use log4j to capture the log message and it doesn't support context variable.

Is it working when you use the ${TalendJob.log}? Which creates a log file with the Talend's job name.

Best regards

Sabrina

aksharma
Contributor II
Contributor II
Author

Hi

Thanks for reply

yes ,it works with ${sys:TalendJob.log} but we want to control location of log file generation as well as the log4j.xml file location

 

We can achieve this with  

<RollingFile name="RollingFileAppender" fileName="${log4j:configParentLocation}/${sys:TalendJob.log}" >

 

but we have to pass the log4j.xml file location through jvm parammeters

 

-Dlog4j.configurationFile=C:\Users\aksharma\Downloads\testlogs\log4j2.xml

 

But I am not sure if multiple job/service artifacts can use same location of log4j2.xml file

 

how we can achieve same for multiple rest services generating multiple log files running under same karaf container

 

 

Best Regards

Ashish

Anonymous
Not applicable

Hello,

Thanks for your feedback. We will make an investigation on your issue and then come back to you as soon as possible.

Best regards

Sabrina

aksharma
Contributor II
Contributor II
Author

Hi

 

Do you have any update on this ?

 

Best Regards

Ashish

Anonymous
Not applicable

Hello.

We have reported your issue to our ESB experts and will keep you updated to your issue as soon as we can.

Best regards

Sabrina