Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using ant with Log4jListener - how do I filter out the task events

 
Matthew Knaus
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am running ant from the command line with the following options:

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

My log4j.properties file is as follows:

#
log4j.rootLogger=DEBUG, stdout
# direct messages to stout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.Threshold=error
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%m%n

When I run the ant task, INFO events are output to the terminal:

INFO [main] (Log4jListener.java:63) - Build started.
INFO [main] (Log4jListener.java:118) - Task "property" started.
INFO [main] (Log4jListener.java:131) - Task "property" finished.
INFO [main] (Log4jListener.java:131) - Task "echo" finished.
INFO [main] (Log4jListener.java:118) - Task "java" started.
...

Is there a way I can filer these events?? Do I need to provide an option to ant or something?
javascript:emoticon('');







 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew, welcome to Java Ranch!

I think you need to capitalize the threshold:

log4j.appender.stdout.Threshold=ERROR
 
Matthew Knaus
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it is case insensitive. I am using the jvmarg "-Dlog4j.debug=true", which displays the following output at runtime:


INFO [Thread-3] (Log4jListener.java:163) - log4j: Parsing appender named "stdout".
INFO [Thread-3] (Log4jListener.java:163) - log4j: Parsing layout options for "stdout".
INFO [Thread-3] (Log4jListener.java:163) - log4j: Setting property [conversionPattern] to [%m%n].
INFO [Thread-3] (Log4jListener.java:163) - log4j: End of parsing for "stdout".
INFO [Thread-3] (Log4jListener.java:163) - log4j: Setting property [target] to [System.out].
INFO [Thread-3] (Log4jListener.java:163) - log4j: Setting property [threshold] to [ERROR].
INFO [Thread-3] (Log4jListener.java:163) - log4j: Parsed "stdout" options.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the jvmarg "-Dlog4j.debug=true"

That explains it - if you are asking Log4J to debug its own code no wonder you are getting INFO output for Log4jListener.
 
Matthew Knaus
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured out my problem and hope this can help someone else. I was unable to filter out the messages that are logged in Log4jListener when running ant with the following options:

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

I added the jvmarg "-Dlog4j.debug=true" and noticed that several messages were output to the console before log4j was initialized! I found that you can configure log4j in build.xml instead of using the -listener command line option. I no longer get annoying info messages with this configuration.

My build.xml looks like:


Cheers!
- Matt


 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic