ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: two listeners but only different logging
Date Fri, 22 Oct 2010 13:10:43 GMT

AntPerformanceListener handles log events for ANT events here are the impelemented methods


public class net.sf.antcontrib.perf.AntPerformanceListener extends java.lang.Obj
ect implements org.apache.tools.ant.BuildListener{
    public net.sf.antcontrib.perf.AntPerformanceListener();
    public void buildStarted(org.apache.tools.ant.BuildEvent);
    public void buildFinished(org.apache.tools.ant.BuildEvent);
    public void targetStarted(org.apache.tools.ant.BuildEvent);
    public void targetFinished(org.apache.tools.ant.BuildEvent);
    public void taskStarted(org.apache.tools.ant.BuildEvent);
    public void taskFinished(org.apache.tools.ant.BuildEvent);
    public void messageLogged(org.apache.tools.ant.BuildEvent);
    public static void main(java.lang.String[]);
}

but the stdout Log appenders you will be sending to are not configurable appenders 
if you desire to send the output to anywhere else other than stdout you would need to implement
Log4jListener here is the JavaDoc

Passes build events to Log4j, using the full classname's of the 
generator of
each build event as the category:
build started / build finished - org.apache.tools.ant.Projecttarget started / target finished
- org.apache.tools.ant.Targettask started / task finished - the fully qualified classname
of 
the taskmessage logged - the classname of one of the above, so if a task 
logs a
  message, its classname is the category used, and so on.
All start events are logged as INFO.  Finish events are either logged
 as
INFO or ERROR depending on whether the build failed during that stage. 
Message
events are logged according to their Ant logging level, mapping directly
 to a
corresponding Log4j level.


ant -listener org.apache.tools.ant.listener.Log4jListener


To use Log4j you will need the Log4j JAR file and a 
'log4j.properties'
configuration file.  Both should be placed somewhere in your Ant
classpath. If the log4j.properties is in your project root folder you 
can
add this with -lib option:


ant -listener org.apache.tools.ant.listener.Log4jListener -lib .


If, for example, you wanted to capture the same information output to
 the
console by the DefaultLogger and send it to a file named 'build.log', 
you
could use the following configuration:


log4j.rootLogger=ERROR, LogFile
log4j.logger.org.apache.tools.ant.Project=INFO
log4j.logger.org.apache.tools.ant.Target=INFO
log4j.logger.org.apache.tools.ant.taskdefs=INFO
log4j.logger.org.apache.tools.ant.taskdefs.Echo=WARN

log4j.appender.LogFile=org.apache.log4j.FileAppender
log4j.appender.LogFile.layout=org.apache.log4j.PatternLayout
log4j.appender.LogFile.layout.ConversionPattern=[%6r] %8c{1} : %m%n
log4j.appender.LogFile.file=build.log

http://ant.apache.org/manual/listeners.html#Log4jListener

Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist
unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet
keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen
wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe
quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information
seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les
email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune
responsabilité pour le contenu fourni.




> Date: Fri, 22 Oct 2010 04:36:07 -0700
> From: kiran.ciba@wipro.com
> To: user@ant.apache.org
> Subject: two listeners but only different logging
> 
> 
> Hi,
> I am using two listeners : 
> net.sf.antcontrib.perf.AntPerformanceListener
> org.apache.tools.ant.listener.Log4jListener
> 
> I want all print statements other than 'performance statistics' to be
> printed on the console. so that means i cannot use the -logFile option.
> 
> How can we implement this differentiated behaviour of listeners in ant? 
> -- 
> View this message in context: http://ant.1045680.n5.nabble.com/two-listeners-but-only-different-logging-tp3232109p3232109.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message