This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

using the log4Jlistener in ant

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone point me to some sample configuration files for using the log4jListener for logging in ant? The only documentation I found through google documents using the -listener property when envoking ant, but it is not clear to me where Log4j will get its configuration information from. i.e do I configure it via the build.properties used by ant, by a log4j.properties file located ??? in ants home directory? in the cwd directory, in the build root?
Thanks in advance for any help
Jeff Gaer
 
Sheriff
Posts: 3034
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The log4j jar should be in your Ant lib, and the log4j.properties should be in your current directory, i.e., where the build.xml is.
Here's an example that keeps rolling log files for builds, and e-mails you when there is an error.
(This example comes from Java Development with Ant by Erik Hatcher and Steve Loughran, Copyright (c) 2003, Manning Press.)

log4j.rootCategory=INFO,file
log4j.category.org.apache.tools.ant.Project=INFO,file,mail
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.layout=org.apache.log4j.TTCCLayout
log4j.appender.file.file=build.log
log4j.appender.file.maxBackupIndex=3
log4j.appender.file.maxFileSize=100KB
log4j.appender.mail=org.apache.log4j.net.SMTPAppender
log4j.appender.mail.layout=org.apache.log4j.HTMLLayout
log4j.appender.mail.Threshold=ERROR
log4j.appender.mail.SMTPHost=localhost
log4j.appender.mail.bufferSize=1
log4j.appender.mail.to=erik@example.org
log4j.appender.mail.from=erik@example.org
log4j.appender.mail.subject=Build Failure!
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!