But it doesn't hurt to ask. Is there any programmatic mechanism within Ant to arbitrarily query what the current log level is? For example, can the task I'm implementing find out whether the user has invoked Ant with the -verbose option? The analogous functionality in Commons Logging or Log4j would be a method like Log.isDebugEnabled or Logger.isDebugEnabled. See: http://commons.apache.org/logging/apidocs/org/apache/commons/logging/Log.html#isDebugEnabled%28%29
What I'd like to do is invoke getProject().log("Some message", Project.MSG_VERBOSE) only if the current log level is verbose. One observation that leads me to figure there is no such API is that, when I look in the Ant source, I see passages like the following excerpt from the topoSort method in the Project class: StringBuffer buf = new StringBuffer("Build sequence for target(s)"); for (int j = 0; j < root.length; j++) { buf.append((j == 0) ? " `" : ", `").append(root[j]).append('\''); } buf.append(" is " + ret); log(buf.toString(), MSG_VERBOSE); So there's an example of code that's always being executed even if chances are it's never being used.