2

I have a Java application that launches a Perl program using Runtime.exec, waits for it to return and then continues. I would like the log4j output from the Java application and the log4perl output from the Perl program to go to the same file.

In my log4j.properties file, I have:

log4j.appender.app=org.apache.log4j.DailyRollingFileAppender log4j.appender.app.File=/path/app.log log4j.appender.app.DatePattern=.yyyy-MM-dd log4j.appender.app.Append=false log4j.appender.app.layout=org.apache.log4j.PatternLayout log4.appender.app.layout.ConversionPattern=%5p [%t] (%F:%L) %m%n

(I've set Append to false because if the Java application is relaunched, I want to overwrite any previous log file from the same day.)

In the Perl program, I have:

Log::Log4perl->easy_init({level => $DEBUG, file => ">>/path/app.log"});

This results in the log4j output, followed by the log4perl output, going to the same file, but when the Perl program finishes, the Java application cannot seem to write to the file anymore.

Can I reset my file handle on the Java side somehow? Can I somehow pass the logger to the Perl program instead of the filename?

I thought of sending output from both to the console and then saving that to a file, but that would be a loss of functionality for me since I'm taking advantage of sending different levels of output to the console and the file.

AJ11
  • 21
  • 2

0 Answers0