>I am writing an installation program using Ant. Currently I am running my >program in quiet mode. This way, I can send user information requests >[input] to the screen as well as [echo] specific information that I want the >user to see. I can also send other debugging and logging information to >various log files. > >This is all easy. I have written a couple of simple macros, which makes it >even easier and gives me more control. > >I want to know if there is an easy and automatic way to at the same time as >the above, send the automatically generated verbose information to a log >file, without sending it to the screen. For example a replace task generates >some verbose information (and a summary), that I want sent to the log file, >but not the screen. > >I could manually echo some info to the log, e.g. the token and the value for >example. I have to problems with this: >1) It is manual, not automatic >2) I don't have access to that internal verbose information, >for example the >replace summary. [replace] Replaced 6 occurrences in 0 files. > >I know that you can override the logger. I have looked for a >logger that >does what I want, but not found anything yet. Can anyone >recommend one and >some tips or examples of how to get it to do what I want it >too? It seems >like Log4J could be setup to do this, but it looks a bit complicated. > >I am also already using AntXtras for things like variables and looping >tasks. If you are not using AntXtras, yet, I highly recommend >this, it fills >a lot of the gaps in Ant and is really easy to use. I see >AntXtras has some >special support for Log4J, but I have not looked into this yet. Perhaps >someone can give me some pointers on how to use AntXtras to do >the type of >logging that I need. > >I don't have any Java experience, so I am not in a position to >be able to do >my own implementation. > >I would even settle for a script internal task to manually >switch between >verbose logging to file and quiet logging to the screen, as >and when I want >to switch.
Basically you use multiple loggers and different loglevels. The DefaultLogger for printing to STDOUT with ECHO level and the FileLogger for DEBUG level. When using Log4J you have the most control about the output. Using Log4J is not complicated: $ant -listener org.apache.tools.ant.listener.Log4jListener -Dlog4j.configuration=log4j.properties lgo4j.properties # Configuration Appender "STDOUT" log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout log4j.appender.STDOUT.layout.ConversionPattern=%m%n log4j.appender.STDOUT.threshold=WARN # Configuration Appender "FILE" log4j.appender.FILE=org.apache.log4j.FileAppender log4j.appender.FILE.layout=org.apache.log4j.PatternLayout log4j.appender.FILE.layout.ConversionPattern=%-5p (%F:%L): %m%n log4j.appender.FILE.file=ant.log # Which Appender to where? log4j.rootLogger=DEBUG, STDOUT, FILE When writing an installer - I think there are some on the market http://antinstaller.sourceforge.net/ Jan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org