Return-Path: Mailing-List: contact user-help@ant.apache.org; run by ezmlm Delivered-To: mailing list user@ant.apache.org Received: (qmail 38264 invoked from network); 28 Mar 2003 11:13:46 -0000 Received: from mailgate.intershop.de (217.17.202.241) by daedalus.apache.org with SMTP; 28 Mar 2003 11:13:46 -0000 Received: from jena02.net.j.ad.intershop.net (jena02.net.j.intershop.de [10.0.87.192]) by mailgate.intershop.de (8.11.6/8.11.6) with ESMTP id h2SBDur12002 for ; Fri, 28 Mar 2003 12:13:56 +0100 (MET) Received: by jena02.net.j.ad.intershop.net with Internet Mail Service (5.5.2655.55) id ; Fri, 28 Mar 2003 12:13:55 +0100 Message-ID: <770E451830D96B4D84747B54665DA1B201C2D803@jena03.net.j.ad.intershop.net> From: Joern Engmann To: "'user@ant.apache.org'" Subject: Unexpected behaviour of Ant task logging Date: Fri, 28 Mar 2003 12:13:54 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2655.55) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2F51B.1E8044C0" X-Virus-Scanned: by AMaViS-perl11-milter (http://amavis.org/) X-Spam-Status: No, hits=-99.2 required=100.0 tests=EXCHANGE_SERVER,HTML_FONT_COLOR_BLUE,MIME_NULL_BLOCK, SPAM_PHRASE_02_03,USER_IN_WHITELIST version=2.44 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C2F51B.1E8044C0 Content-Type: text/plain; charset="ISO-8859-1" Hi! I found an unexpected behavior of the Ant task. When I use a special logger in the parent process, normally I want to use the same logger type for the sub process. At this time the Ant task uses DefaultLogger in any way. Additionally its not possible to set a special Logger in the Ant task. The following code should solve the Problem. It would be nice if it could be in the next releases of Ant. protected void initializeProject() { newProject.setInputHandler(getProject().getInputHandler()); Vector listeners = getProject().getBuildListeners(); final int count = listeners.size(); for (int i = 0; i < count; i++) { newProject.addBuildListener((BuildListener) listeners.elementAt(i)); } if (output != null) { File outfile = null; if (dir != null) { outfile = FileUtils.newFileUtils().resolveFile(dir, output); } else { outfile = getProject().resolveFile(output); } //changed Code try { out = new PrintStream(new FileOutputStream(outfile)); BuildLogger logger = null; if (loggerName!=null) { logger = (BuildLogger)Class.forName(this.loggerName).newInstance(); } else { int i = listeners.size()-1; while ((!(listeners.elementAt(i) instanceof BuildLogger)) && (i > -1)) i--; if(i > -1) logger = (BuildLogger)listeners.elementAt(i).getClass().newInstance(); else logger = new DefaultLogger(); } logger.setMessageOutputLevel(Project.MSG_INFO); logger.setOutputPrintStream(out); logger.setErrorPrintStream(out); newProject.addBuildListener(logger); } catch (Exception ex) { log("Ant: Can't set output to " + output); } } ... } //additional code protected String loggerName = null; public void setLogger(String logger) { this.loggerName = logger; } ------_=_NextPart_001_01C2F51B.1E8044C0--