Two projects: the product (project-A) and the auto benchmark project for A (project-B).
In B's build file, we need to call A's build file to run the build and bundle-with-app-server process like this:
<ant antfile="${build-file-A}" inheritall="false" target="all" />
And, in project B, we have a lot of Ant tasks that output messages using java.util.logging (The JDK Logging Framework).
The problem is, after that line, all the jdk logger outputs disappear.
With debugging, I find that, during the initialzation of project A's build file, a staticly defined thing in project A will run LogManager.readConfiguration(InputStream)
, which loads a config file that only contains the logger configuration of a single class.
And during readConfiguration
, LogManager.reset()
will be called; during reset
, each handler of each logger will be removed. As <ant>
will load the target build file to the same process of the caller, all the handlers will be removed.
So, except the configurated one, every other class that use jdk logger can't output messages due to lack of output handler.
My question is:
Is there any way to solve this problem, other than:
<exec>
to run project A's build file;readConfiguration()
to restore the default JDK logging settings from the default configuration file after the <ant>
call.Please note that I can't modify project A to prevent the problem.
Typically, Ant's build file, called build. xml should reside in the base directory of the project. However, there is no restriction on the file name or its location. You are free to use other file names or save the build file in some other location.
Ant builds are based on three blocks: tasks, targets and extension points. A task is a unit of work which should be performed and constitutes of small atomic steps, for example compile source code or create Javadoc. Tasks can be grouped into targets. A target can be directly invoked via Ant.
Ant tasks are the units of your Ant build script that actually execute the build operations for your project. Ant tasks are usually embedded inside Ant targets. Thus, when you tell Ant to run a specific target it runs all Ant tasks nested inside that target.
The build. xml file is an Ant script that is created by the PDE to take your plug-in components and combine them into a deployable format. This file compiles and archives your plug-in source code into a single JAR file.
You might be able to create subclass of LogManager
and override reset
and the two readConfiguration
methods to install the handlers you need. Then use the java.util.logging.config.class
system property to install your custom code on statup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With