views:

236

answers:

1

I have a mess I would like to attach log4j logging to. Let me try to explain the process.

  1. Third-party application launches a JVM and loads Main.jar. Main.jar includes a properties file for log4j logging and code to read it in with a PropertyConfigurator. Logging in Main.jar works.
  2. Later, third-party application loads JythonApp.jar.
  3. JythonApp.jar starts up a Jython interpreter and runs a script which uses classes from Main.jar, included by appending the Main.jar to sys.path. This is where the logging fails. The classes used by the Jython script have logging calls, but they do not log.

Any ideas how to make this all work? If you need more information, I will certainly understand and happily provide it.

+1  A: 

I'm guessing that in the Jython case the classes are be loaded by a different classloader, and hence in effect that the log4j logging there is reinitialised, presumably not by the same PropertyConfigurator. Is that possible?

In which case you need to figure out how that log4j is being initialsied. Possibly you can provide a log4j.properties file of your own, perhaps specifying its location with the system property (-D as a launch argument)

log4j.configuration
djna
I can't do anything with the launch arguments that the third-party application uses to run the JythonApp.jar. I think you are correct about the cause though, because I duplicated the exact configuration in JythonApp.jar and then it worked. The problem then is that these two log4js are separate, so unless they implement file locking, the file output will not be safe if they go to the same file. Ideas? Can I somehow make the same log4j work with both jars?
Daniel Straight
Sounds pretty tough. Can you find your wauy into the Main.jar? Insert your own code, replace what's already there? I wouldn't normally contemplate this, but for problem diagnosis it may be necessary.
djna