Sample log4j or logging.properties file

Hi all,

 

Im using Liquibase via ANT tasks in a production environment and need to log the output of the console logging to a file also, as when clients install DB, we need to record output and sometimes trouble shoot.

 

I have added the liquibase-jul-1.0.jar to my ANT classpath, but I dont know how to configure the logger with a properties file? And where this file goes? Do I also have to pass in an ANT system property so that ANT picks up the file?

 

Im open to using either log4j or java logging, so any complete example is appreciated. I dont see any posted on forums or the extensions portal.

 

Thanks a lot for the effort on this great product,

 

Colm

 

P.s im also interestd in logging the SQL to a file too… Is P6SPY the best practice mechanism for this?

 

 

I’m not entirely sure how to help you here; as the link mentions, java.util.logging construct, not a Liquibase construct, and not anything that my logging extension looks for explicitly.  Java’s logging configuration affects the JVM as a whole, regardless of what tool you might happen to be running.

I would invest your time in reading the link I mentioned to understand how Java logging works.  It will help you in other projects as well.

Best,
Laird


http://about.me/lairdnelson

For java.util.logging, here is the guide on all things related to how it works: http://docs.oracle.com/javase/6/docs/technotes/guides/logging/overview.html

In case you are using Glassfish, you’ll find the logging.properties file in $GLASSFISH_HOME/domains/domain1/config/logging.properties.

Best,
Laird


http://about.me/lairdnelson

Laird,

 

Thanks for the reply, so I am persuming that once I have a logging.properties file, I only need to have the Liquibase Juli extension on my classpath and the logging.properties file (say in same directory as build.xml) for Liquibase to pick it up?

 

I suppose Im not clear on how Liqubase finds this file, without me explicitly passing it a location via Ant, command line or otherwise… and in my environment, im running liquibase standalone via ANT tasks…

 

Colm

Im posting my solution, I decided to use a Log4J ANT listener to pipe the console output of ANT to a file.

 

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

 

My ANT command is something like this… (log4j stuff is in relative folder “tools” - and added to classpath via -lib)

 

ant -listener org.apache.tools.ant.listener.Log4jListener -lib tools. create-daffy-database-objects-from-changeover

 

log4j.proeprties file contents… 

 

log4j.rootLogger=INFO, 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.UnknownElement=OFF
log4j.logger.org.apache.tools.ant.taskdefs.Echo=WARN
log4j.logger.org.apache.tools.ant.DatabaseUpdateTask=ALL
DatabaseUpdateTask=ALL

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=${patch}build.log

 

Thanks Laird for you responses, however my original question, I beleive - was not connected to Log4J or Java logging, I already am familar with these tools - its specifically targeted at other peoples experiences of how to use Ant and Liquibase (with Logging extensions). I was hoping someone could share what they did so I could cross reference.

 

Simply, in my case Liquibase was not picking up my logging configuration. I was not sure why, perhaps because the ANT process was spawning a new JVM instance when starting liquibase, which did not inherit the original classpath? (guessing here?) …  anyhow, I think some documentation on how people set up this kind of logging would be useful to end-users.

 

Many Thanks.