Here is my situation : I'd like to control the amount of the info that my custom task puts on the screen according to verbosity settings that user passes in the commanline (-verbose, -debug etc.). The task itself is a wrapper around the existing code that uses System.out/System.err and I can manipulate the level of its' output with a set of proprietary parameters. But I can not match them with Ant's message level since I have no access to it at runtime. It would be nice to have something like Project.getMessageOutputLevel() that returns the current message level set from the command line. Of course my other alternative is to provide something like 'verbose' attribute on my task but this is ugly since I have to explicitly set this flag every time rather than automatically inheriting user settings.
Here is the problem. The output level choice in ant is a final decision made by the output listeners and loggers, not something that is actually known by the logging components you call at logging time. This is different from log4j and siblings where you can go log.isDebug(). That said, I think the project does know what its invocation parameters are and there is no reason why the command line choice cannot be stored somewhere. One thing I have been debating doing, so as to control the amount of info generated by some Axis tasks that log via commons-logging, is to write a commons logging compatible logger that routes all log info to the ant logger. I will try working on this again; it may need some tweaks to the commons logger itself. If we add this, and your code moves to the commons logger API (a good practise, IMO), then you could leverage this functionality.
I've been considering doing the same thing for JDK 1.4 logging, as my tasks often are just wrapper to Ant-independent classes that use java.util.logging. How about I wait on you to provide a nice abstract base class that does most of the work ;-) Cheers, --DD
*** Bug 23688 has been marked as a duplicate of this bug. ***