Re: How to use log4j (log4j.xml) and Maven and Junit??

2007-02-24 Thread gerold kathan
hi - i have exactly the same issue:
* i did what you mentioned (1-3)
* yes it copies the log4j.xml to the right place under src/test/
* BUT the testrunner the complains that it cannot find the file under the 
projects root directory (where also the pom.xml sits)

log4j:ERROR Could not parse file [log4j.xml].
java.io.FileNotFoundException: D:\_devel\_java\_workspace\springtest\log4j.xml 

= but he should look under

D:\_devel\_java\_workspace\springtest\target\test-classes\log4j.xml


= the call from the java source to the log4j.xml looks like
static
{
DOMConfigurator.configure(log4j.xml);
logger = Logger.getLogger(AppTest.class);
}


strange - any hints on that ?




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to use log4j (log4j.xml) and Maven and Junit??

2007-02-24 Thread Jacob Kjome

At 07:29 AM 2/24/2007, you wrote:
hi - i have exactly the same issue:
* i did what you mentioned (1-3)
* yes it copies the log4j.xml to the right place under src/test/
* BUT the testrunner the complains that it cannot find the file under the
projects root directory (where also the pom.xml sits)

log4j:ERROR Could not parse file [log4j.xml].
java.io.FileNotFoundException: 
D:\_devel\_java\_workspace\springtest\log4j.xml


= but he should look under

D:\_devel\_java\_workspace\springtest\target\test-classes\log4j.xml


= the call from the java source to the log4j.xml looks like
static
{
DOMConfigurator.configure(log4j.xml);
logger = Logger.getLogger(AppTest.class);
}


strange - any hints on that ?


Not strange at all.  You are giving a relative file path which will 
be resolved to the directory where the JVM started, which is likely 
the directory of the pom.xml.  Why are you manually configuring Log4j 
anyway?  Just copy log4j.xml to test-classes and let Log4j's 
autoconfiguration perform the configuration.  There is no reason to 
manually call configure().



Jake



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to use log4j (log4j.xml) and Maven and Junit??

2007-01-24 Thread Jacob Kjome

Try adding something like the following to your log4j.xml, after the existing
logger entry...

root
  level value=warn/
  appender-ref ref=DBUNIT.DEBUG.LOG/
/root

You can always create a separate appender for loggers other than
com.company.sql instead of using the DBUNIT.DEBUG.LOG appender for the
root logger.

I think the log4j.xml file is being found.  You just haven't specified any
appenders for any loggers other than those named after your own package
namespace.


Jake

Quoting Lisa [EMAIL PROTECTED]:





 Jacob Kjome hoju at visi.com writes:

 
 
  Change:
  -Dlog4j.configuration=c:\tmp\log4j.xml  test
 
  To:
  -Dlog4j.configuration=file:///c:/tmp/log4j.xml  test
 
  Or, just copy log4j.xml to the root directory of your compiled test
  classes and let Log4j autoconfigure itself.
 
  Jake
 
 

 Still no luck with either option mentioned.  I searched on where maven stuck
 the
 .class files and copied my log4j.xml there in the same directory.  No luck.

 I did a $which mvn and found mvn, which is a text file and edited it where it
 runs maven, specifically:

 exec $JAVACMD \
   $MAVEN_OPTS \
   -classpath ${M2_HOME}/core/boot/classworlds-*.jar \
   -Dclassworlds.conf=${M2_HOME}/bin/m2.conf \
   -Dmaven.home=${M2_HOME}  \
   -Dlog4j.configuration=file:///C:/tmp/log4j.xml \
   -Dlog4j.debug \
   ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS

 no luck with the above.  Trying to run maven, which is using the surefire
 plugin
 to run tests (.java) which contain log.debug(msg) and have tried everything.

 I am sure this is the script that is running mvn.  I commented out the exec
 JAVACMD section completely and nothing ran so I know it is hitting this
 code
 to run mvn.

 When I run the test cases it always says:
 [INFO] [surefire:test]
 [INFO] Surefire report directory:
 C:\home\projects\branches\rel\sql\target\surefire-reports
 log4j:WARN No appenders could be found for logger
 (com.presence.sql.DbTestCase).
 log4j:WARN Please initialize the log4j system properly.

 ---
 my log4j.xml has an appender like so (copied from another area where log4j is
 working with a file just like this on another system):

 ?xml version=1.0 encoding=UTF-8 ?
 !DOCTYPE log4j:configuration SYSTEM log4j.dtd

 !-- --
 log4j:configuration
 xmlns:log4j=http://jakarta.apache.org/log4j/;
 disable=debug
 debug=true

 !-- ***
 --
 !-- all org.apache messages --
 appender name=DBUNIT.DEBUG.LOG
   class=org.apache.log4j.DailyRollingFileAppender
 param name=File value=logs/dbunit.debug.log/
 param name=Append value=false/
 param name=ImmediateFlush value=true/
 param name=Threshold value=DEBUG/
 layout class=org.apache.log4j.PatternLayout
 param name=ConversionPattern
value=%d %-5p [%t] %c %C (%F:%L) - %m\n/
 /layout
 /appender


 !-- ***   LOGGERS *** --
 !-- DBUNIT (DEBUG) --
 logger
 name=com.company.sql
 additivity=false
 level value=DEBUG/
 appender-ref ref=DBUNIT.DEBUG.LOG/
 /logger
 /log4j:configuration





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to use log4j (log4j.xml) and Maven and Junit??

2007-01-23 Thread James Stauffer

Try putting the log4j.xml in the working directory and not providing a
path (just the filename).  Also run with -Dlog4j.debug to see what
log4j finds.

On 1/23/07, Lisa [EMAIL PROTECTED] wrote:

I have written some JUnit tests and put them in the standard layout for test
cases under Maven.  The tests use log.debug(msg), log.info(msg) etc.

The tests run OK.

So now I created a simple log4j.xml file with an appender and a logger that
filters only the logging messages in my test case (by package).

When I run maven (mvn test), how do I tell it where my log4j.xml is and how to
use log4j logging?

I have tried everything.  I edited the mvn script under the install directory
to include the following:

 exec $JAVACMD \
   $MAVEN_OPTS \
   -classpath ${M2_HOME}/core/boot/classworlds-*.jar \
   -Dclassworlds.conf=${M2_HOME}/bin/m2.conf \
   -Dmaven.home=${M2_HOME}  \
   -Dmaven.junit.sysproperties=log4j.configuration \
   -Dlog4j.configuration=file:C:\tmp\log4j.xml \
   ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS


this does not work (have tried with and without file:.

---
I have included a something similiar on the mvn command line:
   mvn -Dlog4j.configuration=c:\tmp\log4j.xml  test

this does not work (have included =file:c:\tmp... as well

---
I have also tried setting properties in the pom.xml like so:

plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-surefire-plugin/artifactId
configuration
skipfalse/skip
useFilefalse/useFile

systemProperties
property
namemaven.junit.sysproperties/name
valuelog4j.configuration/value
/property
property
namelog4j.configuration/name
valuefile=:c:\tmp\log4j.xml/value
/property
/systemProperties
/configuration
/plugin

---
and

plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-surefire-plugin/artifactId
configuration
skipfalse/skip
useFilefalse/useFile

systemProperties
property
namemaven.junit.sysproperties/name
valuelog4j.configuration/value
/property
property
namelog4j.configuration/name
valuec:\tmp\log4j.xml/value
/property
/systemProperties
/configuration
/plugin

--- and  (log4j.xml is in same directory as pom.xml) this does not work either.


plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-surefire-plugin/artifactId
configuration
skipfalse/skip
useFilefalse/useFile

systemProperties
property
namemaven.junit.sysproperties/name
valuelog4j.configuration/value
/property
property
namelog4j.configuration/name
valuelog4j.xml/value
/property
/systemProperties
/configuration
/plugin


---
none of these work.  Any ideas on how to integrate Maven2, Log4J and Junit would
be greatly appreciated.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
James Staufferhttp://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]